Advertisement
karlakmkj

Built-in Object methods

Dec 18th, 2020
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const robot = {
  2.     model: 'SAL-1000',
  3.   mobile: true,
  4.   sentient: false,
  5.   armor: 'Steel-plated',
  6.   energyLevel: 75
  7. };
  8.  
  9. // What is missing in the following method call? - add object in the parentheses
  10. const robotKeys = Object.keys(robot);
  11.  
  12. console.log(robotKeys);
  13.  
  14. // Declare robotEntries below this line: - to print all key and values of the object
  15. const robotEntries = Object.entries(robot);
  16.  
  17. console.log(robotEntries);
  18.  
  19. // Declare newRobot below this line: - first paramenter is what you want to add, the second is the source of the object
  20. const newRobot = Object.assign({laserBlaster: true, voiceRecognition: true}, robot);
  21.  
  22.  
  23. console.log(newRobot);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement