add each value to array javascript code example
Example 1: how to append item to an array in foreach javascript
for (var i = 0; i < a.length; i++) {
if (a[i] == 1) a.push(5);
console.log(a[i]);
}
Example 2: javascript add 1 to each element in array
var numberarr2 = numberarr.map( function(value) {
return value - 1;
} );