Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //create spaceship object
- let spaceship = {
- 'Fuel Type' : 'Turbo Fuel',
- homePlanet : 'Earth'
- };
- //Function that has object as a parameter that sets the property of 'Fuel Type'
- let greenEnergy = obj => obj['Fuel Type'] = 'avocado oil';
- //Function that sets/reassigns object as a parameter
- let remotelyDisable = obj => obj.disabled = true;
- //invoke the function and pass spaceship as the object
- greenEnergy(spaceship);
- remotelyDisable(spaceship);
- //print spaceship to confirm the changes in the properties
- console.log(spaceship);
- console.log(spaceship['Fuel Type']);
- console.log(spaceship.disabled); //disabled property was added
Add Comment
Please, Sign In to add comment