Displaying people


#1

My code passed but it feels clunky. I'm also getting an "undefined" message printing in the console and am not sure why. Any ideas?


#2

In your contacts array there are 2 names but these values aren't in quotes so the browser doesn't read it as a string variable


#3

console.log() just prints something,the "undefined" is considered as side behavior of it that says it returns "no value".

undefined means "no value"

If you look at printPerson() function,Its already printing result using console.log(),
now while printing, you again use console.log() so it also shows undefined.

take an example..

x = console.log(12) //it will print 12 and return undefined

when you try to do this..

console.log(x)

It will print undefined.

check this out..
LINK - StackO

The first answer clearly mentions..

The console will print the result of evaluating an expression. The result of evaluating console.log() is undefined since console.log does not explicitly return something. It has the side effect of printing to the console.

Note:
If you don't want undefined
just call the function printPerson() with argument.


#4

Thank you so much! This was extremely helpful.


#5

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