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?
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
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
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..
It will print
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.
If you don't want
just call the function
printPerson() with argument.
Thank you so much! This was extremely helpful.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.