For example, how do I achieve the following without iterating over the array?
var a = [1, 2, 3] * 5; // a should equal [5, 10, 15]
You can try this:
function scalarMultiply(arr, multiplier) { for (var i = 0; i < arr.length; i++) { arr[i] *= multiplier; } return arr; }
USAGE
var a = scalarMultiply([1, 2, 3], 5);