Home »
MCQs »
JavaScript MCQs
Which is the correct JavaScript statement to print the addition of two numbers 10 and 20 in a paragraph whose id is 'result'?
15. Which is the correct JavaScript statement to print the addition of two numbers 10 and 20 in a paragraph whose id is 'result'?
- getElementById("result").innerHTML = 10+20;
- getElementById("result").innerHTML = "10+20";
- getElementById("#result").innerHTML = 10+20;
- All of the above
Answer: A) getElementById("result").innerHTML = 10+20;
Explanation:
The correct JavaScript statement to print the addition of two numbers 10 and 2o in a paragraph whose id is "result" is:
document.getElementById("result").innerHTML = 10+20;