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
UPDATED to save the modified values in-place
There's not much reason to log() each value separately. You could streamline the code with something like this, with pretty ES6 arrow functions and ES5 array methods:
var example = [5, 10, 15, 20]
console.log(example = example.map(x => x/100))
Note: arrow functions such as x => x/100
currently work in a very small subset of Web browsers. If you want to publish a web app or page right now, you should use a standard anonymous function: function (x) { return x/100 }
.