0
why the answer is 5?i need help
var arr=[1,2,3,4,5]; for(var i=0;i<3;i++){ arr[i]*=i; } document.write(arr[4]);
1 Answer
+ 5
Because the loop only changes the value of the first 3 cells here (indexes 0 to 2). The cell at index 4 (ie the 5th cell) is left untouched and is still 5.