+ 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 !

16th Nov 2018, 7:35 AM
Rex Hung
3 ответов
+ 7
You should return the function string. getReminder(){ return 'Water the plants' }; console.log(getReminder())
16th Nov 2018, 7:40 AM
Calviղ
Calviղ - avatar
+ 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
16th Nov 2018, 8:09 AM
Zephyr Koo
Zephyr Koo - avatar
+ 1
Thanks
16th Nov 2018, 8:19 AM
Rex Hung