Skip to content

Instantly share code, notes, and snippets.

@McLarenCollege
Last active October 26, 2021 04:19
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/ae699593998e6e78609774a43c280934 to your computer and use it in GitHub Desktop.
Save McLarenCollege/ae699593998e6e78609774a43c280934 to your computer and use it in GitHub Desktop.
Super Heroes

Given the following object, "superheroes" :

  • write a statement to access weight of hulk character using [ ] operator
  • write a statement to add a new item 'nuclear weapon' to powers of Iron man using [ ] operator.
  • write a statement to calculate the total weight of all the different characters using [ ] operator.
  • Do everything again using . operator (if possible)
let superheroes = {
    'hulk': {
        color: 'green',
        powers: ['fly', 'heavy'],
        weight: 200,
        family: 'Marvel'
    },
    'thanos': {
        color: ['brown'],
        powers: ['strong', 'infinity stones'],
        weight: 300,
        family: 'Marvel'
    },
    'superman': {
        color: 'white',
        powers: ['alien', 'fly'],
        weight: 190,
        family: 'DC'
    },
    'iron man': {
        color: 'white',
        powers: ['technical', 'fly'],
        weight: 145,
        family: 'Marvel'
    },
}
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment