A

Admin • 833K Points
Coach

Q. What will be the output of the following JavaScript code?

Code:
<script>
const arr = [10, 20, 30];
let result = 0;

arr.forEach(myFunction);

document.write("Result: " , result)
function myFunction(value, index, array) {
result += value;
}
</script>
  • (A) Result: 60
  • (B) Result: 102030
  • (C) Result: 10,20,30
  • (D) ValueError
  • Correct Answer - Option(A)
  • Views: 28
  • Filed under category JavaScript
  • Hashtags:

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.