Why we are executing the function names despite having the consol.log() statement? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why we are executing the function names despite having the consol.log() statement?

Previously document.write() or console.log() was enough to show the output without executing any function names? We are using varTest() and letTest() end of this code to get the desired output.(ES6) https://code.sololearn.com/W1a0NCSG3WDI/?ref=app

28th Aug 2022, 6:49 AM
Riyad Rahman [π©]
Riyad Rahman [π©] - avatar
1 Answer
0
In the top of the script, you ***define*** the function. The last 2 lines ***call*** the functions, that means they are executed when you run the code. Simply defining a function doesn't execute it. If you removed the last 2 lines, you wouldn't see any output.
29th Aug 2022, 3:56 PM
Lisa
Lisa - avatar