What will be the output of the following JavaScript code? [code] <p id="demo"></p> <script> var numbers = [45, 4, 9, 16, 25]; var ans =

Lượng Tiger

New member
What will be the output of the following JavaScript code?
Code:
<p id="demo"></p>
<script>
var numbers = [45, 4, 9, 16, 25];
var ans = numbers.reduce(myFunction);
document.getElementById("demo").innerHTML = sum;
function myFunction(total, value, index, array) 
{
  return total + value;
}
</script>
A. 100
B. 99
C. 0
D. error
 

Tìm kiếm

Back
Top