+ 1
How I can increase num 80 every time the loop is running?
function chess(){ var arr =[]; for (var i=0;i<4;i++){ var num = 0; arr.push(num); } var newsl = arr[0]+","+arr[1]+","+arr[2]+","+arr[3]; return newsl; } console.log(chess());
4 Respostas
+ 1
You could set num to 80 * i
+ 1
for(var i=0;i<4;i++)
{
var num = 80 * i;
arr.push(num);
}
Hope this helps ☺️☺️.
0
but for that I have to set increment statement to i+=80; and condition to i < value;
is there any other way?
0
no, i increases by 1 for every iteration, so num will be 0, 80, 160, 240 and so on so the increment statement doesn't need to change