Please help me... | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Respostas
+ 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