Nesting for loopsss

what’s wrong here guys?

for (var i = 0; i < arr.length; i++) {
    for (var j = 0; j < arr[i].length; j++) {
      product = product * arr[i][j];
    }
  }

It would help to know what challenge you are on.
Please provide the link.

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Hello there.
What is wrong is kinda hard to see but I guess you want to add product * arr[i][j] to product, but what you are doing is just assigning. I guess you wanted to do += instead of =.
Is that it?

If you are computing a product, you shouldn’t be using +=.

Absolutely - I just had no idea what the colleague wanted exactly:D
Could be *= for all we know.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.