Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active March 11, 2022 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save McLarenCollege/648eb5354c0ae5bc1b26cf5f376ce035 to your computer and use it in GitHub Desktop.
Save McLarenCollege/648eb5354c0ae5bc1b26cf5f376ce035 to your computer and use it in GitHub Desktop.
Exercise : Student Object Exercise Part One
let students = [
{ name: 'Vivek', scores: [70, 90, 60, 91] },
{ name: 'Akshat', scores: [90, 80, 80, 60] },
{ name: 'Arnav', scores: [70, 60, 90, 90] },
];

//To calculate the grade obtained by the student look at below explanation.
// Average score greater than or equal to 91 -> A grade
// Average score greater than or equal to 81 -> B grade
// Average score greater than or equal to 71 -> C grade
// Average score greater than or equal to 61 -> D grade
// For other average scores -> E
  • Task1 : Draw the Object Diagram for the given Array of Objects.
  • Task2 : Write the code to print the name of the first student.
  • Task3 : Write the code to print the length of the scores array for the first student.
  • Task4 : Write the code to calculate the average score for the first student.(TIP: first create a variable which point to students[0].scores, then use it to calculate the average)
  • Task5 : Write the code to calculate the grade for the first student and print out the name of the student followed by his grade.
  • Task6 : Write the code to add the calculated grade for the first student as a property to the object.
  • Task7 : Update the Object Diagram you created in Task1 with the grade property.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment