I'm trying to learn more about arrays and so I just wrote this simple function:
(I'm calling doThis from an onClick for testing purposes).
function doThis() {
var multiplier = 3;
var list = [23, 54, 23, 25, 65];
var products = multiply(list, multiplier);
console.log(products);
}
function multiply(list, multiplier) {
list.forEach(function (element){
var multi = [element * multiplier];
console.log(multi);
return multi;
});
}
My issue is two-fold:
var productsis returningundefined.- When I step through the code in the debugger, it shows the arithmetic being done correctly, but it doesn't store more than one value in the variable
multi.
The end goal would be to have var products hold the multi array.