Challenge Hints: Nested Loops

A list of hints for the challenges in the Nested Loops lesson..

Last updated - July 23, 2024

 

Checkpoint

Did you declare an array "students" with at least 3 names?

Did you declare an array "commonInterests" with at least common interests?

Did you declare a for loop that iterates through the students array? Use the array length method!

Inside the students for loop, did you declare a second for loop to go over the commonInterest array? Use the array length method!

Did you log a statement to the console in the second for loop?

Missing Numbers

Did you declare an initial for loop to iterate through all possible digits for the first value?

Did you declare a second, nested for loop to iterate through all possible numbers?

In the second for loop, did you use concatenation to log all possible numbers to the console? (i.e 021-3440)

Food Order

Did you prompt the user for the number of categories they are breaking the list down to?

For the number of categories, get each name of the category and push it to an empty array

Did you declare a for loop to iterate through the newly declared array?

In the for loop, did you declare a while loop to get the item from the user and push it to the array?

Check if the user has more items to get, if not then move on to the next category

Once all categories have been visited, log the list to the console

Bowling

Did you declare an array to hold the names of the players? There should be at least 4 players

Did you declare 4 empty arrays to hold the score for each player?

Did you declare an outer for loop to iterate through all the frames in a game?

Did you declare a second, nested for loop that will iterate through the array of the players names?

Did you check to see which player it is, get the score for the frame, and push it back to the appropriate array?

Once all the scores have been collected, did you log each array to the console?

Asterisk Printer

Did you prompt the user for the number of asterisks that they would like to print?

Did you declare a while loop that continues while the number of asterisks is greater than or equal to 0?

In the while loop, did you have a for loop iterate through the number of asterisks to be printed and log one to the console?

Once the for loop has been completed, did you prompt the user for the next number of asterisks to be logged to the console?

Class Survey

Did you declare an array to hold the questions to be asked for the survey?

Did you declare a number variable for each questions that will be asked? There should be at least 3, one for each question

Did you get the number of students in the class?

Did you declare a for loop that would iterate through all of the students

Did you declare a second, nested for loop that will iterate through the survey questions and prompt each one?

If the answer was yes, did you increment the corresponding variable?

Once the loops were complete, did you log each variable total to the console?

For more help with JavaScript, check out our JavaScript Reference Guide!