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'?

  1. getElementById("result").innerHTML = 10+20;
  2. getElementById("result").innerHTML = "10+20";
  3. getElementById("#result").innerHTML = 10+20;
  4. 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;

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.