Lượng Tiger
New member
What will be the output of the following JavaScript code?
A. 100
B. 99
C. 0
D. error
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>
B. 99
C. 0
D. error