Unnest Nested For Loop

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

  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

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.

Link to the challenge:

Just because you can do something, it does not mean that you should!

That is making my eyes bleed :slight_smile:

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())

If this is how you speak, remind me not to get caught chatting with you in the kitchen at a party :wink:

tbh, I mentally resist for-loops these days unless it’s a dire emergency - it’s probably just my brain throwing up defenses.

If I saw this line of code at work though, I’m pretty sure I’d throw my laptop out of the window.