+ 1
Please help me...
I have another question in JS Ex. function getReminder(){console.log('Water the plants')}; console.log(getReminder()) Output: Water the plants. Undefined Why output have undefined? Thanks !
3 Respostas
+ 7
You should return the function string.
getReminder(){ return 'Water the plants' };
console.log(getReminder())
+ 3
Calviղ was right as the console log actually display the object within its brackets.
In this case, the function getRemainder just execute the statement without return and hence there are nothing to display — undefined
You may find more usage and information at:-
https://developer.mozilla.org/en-US/docs/Web/API/Console/log
+ 1
Thanks