what is the difference? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

what is the difference?

case1: it works function addNumbers(a,b){ var c = a+b; return c; } document.write(addNumbers(5,6)); case2:but this doesn't work: function addNumbers(a,b){ return a+b; } var c = addNumbers(5,6) case3: again, this looks similar to the 2nd case bt it works: function myFunction(a,b){ return a*b; } var c = myFunction(5,6); i would like to know, why case2 doesn't give answer, as in case1...and what makes t be different from case3(not the sign of operation)

19th Mar 2017, 5:48 AM
Kelvine De Danielo
Kelvine De Danielo - avatar
5 Réponses
+ 4
add a ; at end of var c
19th Mar 2017, 6:01 AM
Eldar Bakerman
+ 2
var c = addNumbers(5,6); as @Eldar said...the semicolon ; at the end of this expression was missing.... you didn't forget it for the other examples that's why they worked but not that one...
19th Mar 2017, 10:41 PM
Arcturus
+ 1
you have space between brackets and 5 in the 2nd example
19th Mar 2017, 5:53 AM
Eldar Bakerman
+ 1
Was it helpful? If so, please mark your question ad answered by selecting my answer as the best one.
19th Mar 2017, 6:08 AM
Eldar Bakerman
0
i have removed the space but still does not give 11...
19th Mar 2017, 5:59 AM
Kelvine De Danielo
Kelvine De Danielo - avatar