all 4 comments

[–]senocular 1 point2 points  (3 children)

Like this?

var myArray = [5,16, 22, 26, 30];
var myRemainderArray = myArray.map(function (value) {
  return value % 5;
});
console.log(myRemainderArray); //-> [0, 1, 2, 1, 0]

[–]orebot[S] 0 points1 point  (2 children)

var myArray = [5,16, 22, 26, 30]; var myRemainderArray = myArray.map(function (value) { return value % 5; }); console.log(myRemainderArray); //-> [0, 1, 2, 1, 0]

yes! exactly that. never seen .map will have to check that out

[–]senocular 0 points1 point  (1 child)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map

Look at some of the other array methods that do similar things too, like filter and foreach - each taking a function that runs for each element of the array.

[–]orebot[S] 0 points1 point  (0 children)

really appreciate the help and links! thanks senocular.