I can't see where the "Undefined" output is coming from and how can I remove it and the LINK is https://www.codecademy.com/workspaces/61e1ca7dd2756881fd6d49ec

I can’t see where the “Undefined” output is coming from and how can I remove it and the LINK is https://www.codecademy.com/workspaces/61e1ca7dd2756881fd6d49ec

Let playGame() do the logging, or change those to returns.

1 Like

thank you mtf for answering
do you mean i should write playgame() and not console.log(playgame);

Correct. That way you won’t be logging the final return (or lack of).

1 Like

Thank you very mtf for answering , it was really helpful insight . the undefined in the output has disappeared.

please can you explain why undefined was there because i really dont get why it was there despite the value have been put there

Functions are like segues, or deviations from the path. However, they always want to return to where they are called from. Like a homing pigeon, we send it off with a message, and await its return with the reply. JavaScript has the behavior built in. There is always a return, even if it is nothing. The pigeon always comes back. Barring our function supplying a return value, the built in return value is undefined. If the caller is logging the return, then that is what will get logged. That includes console.log() itself, being as it too is a function.

console.log(console.log())    //  undefined
1 Like

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