3/6 what is wrong with my code?


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(i){
console.log(contacts[i].firstName + " " + contacts[i].lastName);

it says i did not create a printPerson function


There's your problem. You've got an "i" in between your function parentheses. Try taking it out.


Well, actually I haven't gotten there yet but it looks fishy to me. Am I right, people?


if i take it out, it says i did not define "i" :pensive:


Well, what is i for? I might be able to figure this out...


Define the printPerson function this way

function printPerson(i){
console.log(contacts[i].firstName + " " + contacts[i].lastName);

but notice that this function takes in a person object so all you have to print the attributes of that person like this

function printPerson(person) {
    console.log(person.firstName + " " + person.lastName);


Oh! That makes sense. You see, I'm not really experienced and I haven't even gotten to this section yet, but I try to help where I can. It's just I've never seen something in the function parentheses before, so I thought it was fishy...


"i "means a number. it similar to that one in a for loop. most of people use person to call the function, but i use the order in "contacts" to call the function


Well, try @rydan's response.


Also, while I'm here, could you look at my post "No ideas"? It's in the Code Your Own Adventure 2 section. Thx


@jrpsychgal if you have programmed any other languages before then a function here is analogous to methods in other languages. functions can have no arguments or a set of arguments that you have to pass. You will come across it in the tutorials


thanks rydan, but it dosen't work ,either. so if i name a function with the word person, it means i must use person as the paremeter? dose the name affect the choice of the paremeter inside ()?


Well, JavaScript is actually my second language, if you count HTML and CSS... But I'm really a beginner in actual programming.


thanks man, welcome to share your ideas, it dosen't matter if it is correct or not, we will improve together


Well, maybe Codecademy wants you to use person instead of contacts.


The name does not affect it but the implementationin the function changes a little


so it means my way works actually, but the practice asks me to do another thing? i just noticed the hint said i should use person as the arguement


Hey, um could someone look at my post "No ideas"? I haven't got any answers and my brain is a blank.


using person as the argument just tells the user ohh hey this function expects a person object to be passed as an argument any other argument and the function will not work


This post is old, but I ran into the same issue because I initially coded it the same way you did and I wanted to respond for future reference. The function should work as you wrote it, but you won't be able to move on to the next step.

We want the argument to be contacts at an index rather than just the index.

So your function should be

function printPerson(person) {
    console.log(person.firstName + " " + person.lastName);

and your calls should be