Adding properties


#1


https://www.codecademy.com/courses/javascript-beginner-en-3bmfN/0/4?curriculum_id=506324b3a7dffd00020bf661#


So the Instruction is "Give each of your friends a firstName, lastName, and number. The value for each of these should be a string (check the Hint if you need help). Make sure bill's first name is "Bill" and steve's first name is "Steve" (again, note the capitalization)." But the error is "Oops, try again. It looks like your friends don't have the firstName property". What can I do?


var friends = new Object();

friends.bill = new Object();
    friends.firstName ='Bill';
    friends.lastName =  'Gates';
    friends.number =  '15346354521';
friends.steve = new Object();
    friends.firstName = 'Steve';
    friends.lastName = 'Jobs';
    friends.number = '246543218';
    
friends.july = new Object();
    friends.firstName = 'July';
    friends.lastName = 'Itchon';
    friends.number = '5169516811';


#2

The way you created the objects is right but to add properties to each friend's object, you need to:

friends.bill.firstName = "Bill";

after you created that friend object.

Use this to resolve all.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.