Tossing in an Array


#1



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


Syntax Error: Unexpected String


Replace this line with your code. 

var friends = new Object();
friends.bill = new Object();
friends.steve = new Object();

friends.bill.firstName = "Bill";
friends.bill.lastName = "Cody";
friends.bill.number = "2345678";

friends.steve.firstName = "Steve";
friends.steve.lastName = "Jobs";
friends.steve.number = "3456789";

friends.bill.address = ["One Microsoft Way", "Redmon, CA", "91234"];
friends.steve.address = ["Two Microsoft Way", "Monterey, CA" "91029"];


#2

You are getting unexpected string as you are missing a comma here, between CA" and "91029"


#4

Unexpectant number? Whats the problem here, please?

var friends = {
friendslastname:"Wesley",
friendsfirstname: "Junior",
number: "(415) 510-4089",
address:['332 Something Honeymount Street','NY,'30098']

bill:{
     firstName:"Bill",
     lastName: "Johnson",
     number: "(510) 245-9494",
     address:['1 Universidad Ave', 'Sacramento', 'CA', '73882']
    },
steve:{
     firstName: "Steve",
     lastName: "Mackle",
     number: "(837) 440-3873",
     address:['780 Washington Way', 'Arlingon Ave', 'Kensington', '77383']
    }

};


#5

@cdethis,
You need to understand the build of the friends object

var friends= {
              bill: { firstName: 'Bill',
                      lastName: 'Gates',
                      number: '444-444-4444',
                      address: [ 'One Microsoft way', 'Redwood', 'WA' ]
              },
             steve: {
                      firstName: 'Steve',
                      lastName: 'Jobs',
                      number: '333-333-3333',
                      address: [ 'Two infinite loop', 'Bentown', 'DV' ] 
              }
   };

keep repeating these two lines
An object has one or more properties seperated by a comma-,
Each property consists of a property-key and it's associated value

Description of the friends object.
The friends object has 2 properties and are seperated by a comma-,

there is a bill property with property-key bill and it's associated object value
(this associated object has 4 properties, the property-keys being firstName, lastName,number and address)
there is a steve property with property-key steve and it's associated object value
(this associated object has 4 properties, the property-keys being firstName, lastName,number and address)

So if you want add an other friend to this friends object
you will have to use a format like

junior: {
    firstName: "Junior",
    lastName:"Wesley",
    number: "(415) 510-4089",
    address:['332 Something Honeymount Street','NY','30098']
    }

( you forgot to use a closing-single-quote-' at NY )

You will have to insert this into the existing friends object
as new property so do NOT forget the comma-, separator.....

var friends= {
          bill: { firstName: 'Bill',
                  lastName: 'Gates',
                  number: '444-444-4444',
                  address: [ 'One Microsoft way', 'Redwood', 'WA' ]
          },
         steve: {
                  firstName: 'Steve',
                  lastName: 'Jobs',
                  number: '333-333-3333',
                  address: [ 'Two infinite loop', 'Bentown', 'DV' ] 
          },
          junior: {
                  firstName: "Junior",
                  lastName:"Wesley",
                  number: "(415) 510-4089",
                  address:['332 Something Honeymount Street','NY','30098']
         }
   };

==========================================================

+++ friends list and search and for-in explained.
Look here for an explanation
object
function
for-in-loop
list-function
search-function
http://www.codecademy.com/forum_questions/545275fd8c1ccc8e3e000a23#comment-5457b12c9c4e9d87cb00003f


#6

Thank you!
Thank you!

I just got confused because the computer allowed me to use the first part so I thought that it was correct. I forgot that everything has to match at all times.
I will keep that in mind for future reference.