Why output of this code is nothing? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2
18th Mar 2021, 10:17 PM
🕸carpe diem🕸
🕸carpe diem🕸 - avatar
3 Answers
+ 3
Hi! because you didn't write an output statement to the screen or to the console. document.write() or console.log()
18th Mar 2021, 10:31 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 2
Yep ^^ this : console.log(sum(2,3));
18th Mar 2021, 10:43 PM
Tarantino
Tarantino - avatar
+ 2
🕸carpe diem🕸 easy way to do this based on your own code. function sum(x, y){ result = x + y; return document.write(result); } sum (2, 3); function sum(x, y){ result = x + y; return console.log(result); } sum (2, 3); which will display in the html viewer.
19th Mar 2021, 12:57 AM
BroFar
BroFar - avatar