Why is this incorrect | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why is this incorrect

function myFunction(a, b) { var x= return a * b; } myFunction(5, 6); document.write(x);

12th Jun 2018, 6:51 AM
Yash Mohta
Yash Mohta - avatar
3 Answers
+ 8
this is js..you do not say int a,int b.. thats wrong harsh agrawal. The error is with... var x=return a*b you cannot assign a return statement directly to a variable right syntax is: function myFunction(a, b) { return a * b; } var x=myFunction(5, 6); document.write(x);
12th Jun 2018, 7:04 AM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar
+ 2
🇳🇬Brains ya i think u r right i dont know much about js Sorry for wrong information😢😢
12th Jun 2018, 7:08 AM
Harsh Agrawal
Harsh Agrawal - avatar
+ 1
take d data types in formal parameter as like dis (int a,int b) n u cant return with any variable so plzzzz dont take any variable just write return a*b;
12th Jun 2018, 6:55 AM
Harsh Agrawal
Harsh Agrawal - avatar