FAQ: Advanced Objects - Built-in Object Methods


This community-built FAQ covers the “Built-in Object Methods” exercise from the lesson “Advanced Objects”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Introduction To JavaScript

FAQs on the exercise Built-in Object Methods

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


help! what did I do wrong here?

Now what if we want another object that has the properties of robot but with a few additional properties. Object.assign()

Declare a const variable named newRobot . newRobot will be a new object that has all the properties of robot and the properties in the following object: {laserBlaster: true, voiceRecognition: true} . Make sure that you are not changing the robot object!

const robot = {
	model: 'SAL-1000',
  mobile: true,
  sentient: false,
  armor: 'Steel-plated',
  energyLevel: 75

const newRobot = {laserBlaster: true, voiceRecognition: true,}

const addRobot = Object.assign(newRobot, robot);



Your code above may not be creating the newRobot expected by the SCT.

const newRobot = Object.assign({...}, robot);

We can use the object literal in the first positional argument, or as you have done, create a temporary object. However then we will have a stray object in memory. The literal in the argument is probably the better way to go.


Thank you let me try! It’s unfortunate that they didn’t teach this in the former lesson and in the method MDN it don’t show an example similar to this



As you can see it seems to print out the correct answer… why does it still say incorrect? oh and what do you mean by "Stray Object in memory? your way worked but both give the same output as you can see below


Your code still uses the wrong variable for the new robot. If you wish to use a temporary variable, make it addFeatures, or something, not, newRobot since that is the variable the SCT is checking.

addFeatures = {laserBlaster: true, voiceRecognition: true,} 

newRobot = Object.assign(addFeatures, robot);

The stray object in this case is addFeatures since it never gets called again, just sits in memory taking up space. A very minor concern, here, but later on in more complex code it will be something to keep at a minimum. Intermediary variables are useful, though at times we don’t need them. This is one of those times.


thanks Roy! wow I really had it twisted lol