FCC: Nesting For Loops

Instructions:

Write a function multiplyAll so that it multiplies the product variable by each number in the sub-arrays of arr.

Solution: 

  • Iterate through inner subarrays with j.
  • Then iterate through the outer array with i.
  • Multiply each item with the stored result (product) as you iterate.

screen-shot-2017-01-11-at-11-45-30-pm

Test Cases: 

screen-shot-2017-01-11-at-11-46-10-pm

Advertisements
FCC: Nesting For Loops

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s