in JavaScript by

Which one of the following options is the correct output for the given code of JavaScript?

functionfun()  

{  

var a=1;  

var b=2;  

return a*b;  

}  

document.write(fun());  

a) 2

b) 3

c) 0

d) Error

1 Answer

0 votes
by

Answer: A

Reason: In JavaScript, document.write () is a predefined method which is used for printing output to the console. Here another function in the document.write () method is passed as an argument that returns the multiplication of variables a and b.

Related questions

0 votes
asked Mar 22, 2021 in JavaScript by Robindeniel
0 votes
asked Mar 23, 2021 in JavaScript by sharadyadav1986
+1 vote
asked Mar 22, 2021 in JavaScript by Robindeniel
...