Skip to content

Instantly share code, notes, and snippets.

@cdmz
Created January 26, 2016 01:46
Show Gist options
  • Save cdmz/a5739e47628e30e3e356 to your computer and use it in GitHub Desktop.
Save cdmz/a5739e47628e30e3e356 to your computer and use it in GitHub Desktop.
multiplicar valores array javascript
var squares = [1,2,3,4].map(function (val) {
return val * val;
});
@krakowdeveloper
Copy link

Resolved: 👍
var squares = [1,2,3,4];

let nuevo = squares.reduce(function(total, num){
total = total * num;
return total;
});

console.log(nuevo);

@claravisa
Copy link

what if i want the squared number of each one? 1, 4 , 9, 16

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment