It works, but it seems wrong


#1

Hello!

I really have no idea what is wrong with my code. It does exactly what it should. The function is there and has the correct name, but an error occurs.

I really hope you can help me.

Best regards!


#2

Maybe there shouldn't be any arguments in function. Only ()


#3

Why? The function only works when I pass the array-position with the help of a parameter to contacts[parameter].firstName.


#4

I'm having the exact same problem, it's working, but I am getting an error asking if I created the function called printPerson. The only thing that I can think is that we have not written it exactly as the instructions have requested, however I cannot find the discrepancy.


#5

This thread helped me solve the issue: http://discuss.codecademy.com/t/2-4-somehow-doesnt-work/2036/2


#6

Sorry, but this thread discusses a completely different problem. I work with the correct parameter, the function does what it shlould. It also tried to make the function return the names and let the console log the function as described in the thread. Same problem.


#7

It helped me find the way that the tutorial wants you to respond. I have found these to be finicky, even when you have done things correctly it will not let you move forward until you solve the problem exactly as they want you to.


#8

If you're on step 3: Displaying People, the directions say "Define a function called printPerson that takes a parameter called person."

Therefore in order to pass, you need to use person as your parameter, rather than k. If it had said "Define a function called printPerson that takes a single parameter," without specifying what to use, then k would work.


#9

Yes, I am on step 3. Thank you for the hint, but it still does not work. I tried every option with the parameter called "person", but it still responds with the same error.


#10

Hmm...

I think maybe you're trying to put a little too much into printPerson? I had console.log(person.firstName + " " + person.lastName); and then passed contacts[0] in as the person parameter.


#11

This actually works. Wow. Thanks!

But I don't get why I need to do it in that complicated way. We use functions to minimize the amount of work. "printPerson(0);" is way faster to use than "printPerson(contacts[0]);".


#12

Might be something about bracket notation vs. dot notation. Someone with more experience than me... any thoughts?