Tell us what’s happening:
Did you know you can unnest nested loops?
Your code so far
function addAll(arr) {
var product = 1;
// Only change code below this line
// NOW WATCH THIS!
for (let i = 0, j = 0; i < arr.length; j = j + 1 === arr[i].length ? 0 * ++i : j + 1) product += arr[i][j];
// Only change code above this line
return product;
}
// Modify values below to test your code
addAll([[1,2],[3,4],[5,6,7]]);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.
Strange, my brain finds it incredibly readable. It turns the statement into a sentence that you just need to read from left to right, rather than the whole system of multiline code. If I would ‘speak’ solution it would pretty much match this sentence, rather than a system.
(Of course in real scenario, I would go simpler arr.flat().reduce())