Eirik Langholm Vullum PRO
JavaScript fanatic that loves node.js and React.
for the love of god..
var numbers = [[1, 2], [3, 4], [5, 6]];
var doubled = [];
for(var i = 0; i < numbers.length; i++) {
var entry = [];
for (var j = 0; j < numbers[i].length; j++) {
entry.push(numbers[i][j] * 2);
}
doubled.push(entry);
}
console.log(doubled); //=> [[2, 4], [6, 8], [10, 12]]
var numbers = [[1, 2], [3, 4], [5, 6]];
var doubled = numbers.map(n => n.map(m => m * 2));
Your code should read as a recipe of what to do - not how to do it
By Eirik Langholm Vullum
Internal rant at Scandinavia Online