My code prints the contacts info completely but it says bob jones was not printed to the console. exercise 3


#1


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.com"
};

var contacts = [bob,mary];

var printPerson = function(person) {
    console.log(person.firstName + " " + person.LastName);
}


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


#2

Got a link to that exercise so that one doesn't have to go dig it up?
I would look for a more literal interpretation of the instructions, it might for example not look for printing the first contact, but instead the value that the variable bob refers to. Or it might want you to print using your printPerson function which you aren't currently using.


#3

https://www.codecademy.com/courses/building-an-address-book/0/3?curriculum_id=506324b3a7dffd00020bf661


#4

I can only repeat what I said earlier. Your code doesn't print what the error message says should be printed, compare them!


#5

Hey i am also getting the same problem.i didn't find any thing wrong.could you please elaborate it?


#6

There's nothing to elaborate on. If you print A and B is required, then stop printing B and start printing A.

If there's something you want to know, you'll have to ask, I can't guess. If it's the same problem then the same answer applies and I'm not sure what you're really asking for other than to repeat the same thing. If it's a different problem then it's not the same problem.

Above all, the burden of figuring out what information you need is on you, not for me to just "elaborate"

Etiquette, man, woman, thing, train.


#7

ohh man can't you explain the code or correct me wherever i am making it wrong??the same code is given above.you are saying the thing so correct it wherever it needed.Thanks


#8

I've commented on the above code, you are welcome to use that.
You're also welcome to ask more questions.
You're not welcome to just say HELP ME without explaining what you're looking for, you must understand that I in no way owe you anything and that am governed by my own interests, this is called being another person.

If this is all very strange and foreign to you then I suggest that you go find a few articles about how to successfully ask for help! Incidentally those are also very useful for solving problems yourself.


#9

It says to call the printPerson function so I attempted to but I'm not calling it correctly and I've reviewed my notes on functions. This function call is different somehow, and If I follow the syntax provided in the lesson it comes out incorrect.


#10

If the exercise is asking you to print "Bob Jones" to the console, then why are you using console.log to print contacts bob and mary to the console? What function could you be using? :slight_smile:


#11

Buddy it's given in the lesson to use console.log and if i am removing it then also i am not getting it correct.please help me.tell me what's exactly wrong with my code?


#12

So you are to use your printPerson function to print some person right?

Calling a function f with an argument a looks like this:

f(a)

So you would now need to decide which function you are calling and what argument to provide, and put those in place of f and a in the syntax above

Probably not. Perhaps some new feature? A function is a function, they're called the same way. The number of arguments can vary.


#13

How can people respond to code they haven't seen? I wouldn't know what your code looks like, only the original poster. He posted his code. You haven't started a topic. That's all beside the point though.

This exercise asks you to create a function that will log something specific to the console. In the code block of the function is a console.log statement. Try calling the function you make and see what logs to the console.


#14

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.com"
};

var contacts = [ bob,mary];

// printPerson added here
var printPerson = function(person)
{
console.log( person.firstName +" "+ person.lastName);

}
console.log(contacts[0]);
console.log( contacts[1]);

//here is my code Please have a look and let me know where i am make mistake??


#15

You're not reading the instructions to the exercise.

Call the printPerson() function to print out the first item in the contacts array. The first item in an array is at position 0. Then on the next line, call printPerson() again to print out the second item in the contacts array.


#16

I'm done with this lesson already, forgot to update this post. thanks anyway tho.


#17

This lesson was worded poorly.


#18

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