2/6 I can't see what's wrong


#1

I don't know why, but both of these pieces of code are wrong?

var bob = {
firstName: "Bob",
lastName: "Jones",
phoneNumber: "(650) 777-7777",
email: "bob.jones@example.com"
};

var mary = {
firstName: "Mary",
lastName: "Johnson",
phoneNumber: "(650) 888-8888",
email: "mary.johnson@example"
};

var contacts = [bob,mary];

console.log(contacts[1].phoneNumber);

or replace the last line with

console.log = contacts[1].phoneNumber;

For the first, I get the error
"TypeError: Property 'log' of object is not a function"

For the second I get the number to print, but the bottom of the page says "Oops, try again. Did you remember to print out mary's phone number?"

What am I doing wrong here?


#2

my code is letter for letter with yours and I'm not receiving an error :confused: I wish I could be some kind of help to you but alas that seems not to be the case.


#3

console.log("(650) 888-8888") hope that helps.


#4

There are a lot of ways you can cheeky the lesson to make it work.

you could even make it:

console.log(mary.phoneNumber);

But I'm pretty certain there's no error otherwise in his code.


#5

This is the line that is producing the error message:

console.log = contacts[1].phoneNumber;

because the above statement overwrites the console.log() method with a value so it is no longer a function. This will require a page refresh to restore JavaScript to normal. Be sure to Submit first so your code is saved before refreshing.

After refreshing,

console.log(contacts[1].phoneNumber);

#6

Turns out the browser just was deciding not to work for whatever reason, even with a reload and restart. Didn't change anything from my code above and it worked fine. I guess I didn't sacrifice the goat on the right night to get the computer to work like it's supposed to, haha.


#7

you are very resourceful. lol :smile:


#13