Looping Through An Array and Dividing Each Value By 100

后端 未结 5 1226
Happy的楠姐
Happy的楠姐 2021-01-27 03:44

Hey this is my first question and I\'m just finding my way with JS. I have an array which is set, I want to loop through it and divide each value by 100, then print the output t

5条回答
  •  孤街浪徒
    2021-01-27 04:18

    change the example[i/100] to example[i] /100 and you can console.log each response from inside the for loop.

    var example = [5, 10, 15, 20];
    
    for (var i = 0; i < example.length; i++) {
      console.log(example[i] / 100);
    }
    

提交回复
热议问题