Why console return's undefined?

function getReminder(){
console.log(‘Water the plants.’);
}

So without invoking the function first, I wanted to console.log the function like below

console.log(getReminder());

It returned the following:

Water the plants.
Undefined

Why undefined is returned?

your function does not return anything. Which means you if attempt to log the returned value, you get undefined

1 Like

Hello,

Your code is doing this:
console.log(console.log(‘Water the plants.’);

It will return the content you want, but it will also return undefined because of the double console.log.
I hope that helps.

1 Like

Thank you @stetim94 @mtarichter that explains it.
I think I now understand along with this explantion - https://www.codecademy.com/courses/introduction-to-javascript/lessons/functions/exercises/return

Thank you