Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active November 22, 2022 06:35
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/9fa524b7e641814126f3fc3e5e590484 to your computer and use it in GitHub Desktop.
Save McLarenCollege/9fa524b7e641814126f3fc3e5e590484 to your computer and use it in GitHub Desktop.
Exercise : User Object Manipulation

Given the below object

CODE TEMPLATE


let user = {
  age: 22,
  hasVoted: false,
  name: "vivek",
  location: "India",
  hobbies: ["dance", "music"],
};
console.log(user);

Task1 : Draw the Object Diagram for the above Object. Here is a sample Object Digram for your reference.

Task2 : Create a variable secondHobby and write the code to store the second element of the hobbies array into it.

Task3 : Write the code to add a new property 'favouriteSubjects' to the object and add 'Maths', 'Physics' and 'Chemistry' as the values.

Task4 : Write the code to add a new hobby "swimming" to the hobbies array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment