Challenge Hints: Arrays and Loops

A list of hints for the challenges in the Arrays and Loops lesson.

Last updated - July 23, 2024

 

Checkpoint

Did you use a variable name and brackets [] with a semicolon at the end?

Items in an array need to be separated by commas. Did you remember the semicolon at the end?

Try following the format: for (i = 0; i < myArray.length; i++) { }

Inside the loop you should access the element at each index and add 10. (myArray[index] + 10)

Alphabetical Practice

Did you declare the original array provided?

Did you loop through the array and print each name to the console?

After looping through the array, did you declare a second array with the original having names in alphabetical order

Did you loop through your newly declared array and log each name to the console?

Candy Bowl

Did you declare an array with at least 5 elements?

Did you log each element to the console using a for loop and the array length method?

Did you use another for loop to get 3 additional candies that they would like and add it to the array?

Forward and Reverse

Did you declare an array with at least 5 elements?

Did you use a for loop to print out the contents of the for loop?

Did you print out the contents of the array in reverse using a for loop?

Meals of the Day

Did you declare 3 arrays with at least 3 elements?

Did you declare a for loop that will iterate once for each meal of the day?

If it was the first meal of the day, did you loop through the breakfast array?

Did you check if you need to be looping through the lunch array?

Otherwise, did you loop through the dinner array?

Grand Total

Did you declare a function that accepts an array as a parameter?

Did you loop through the array parameter and compute the sum?

Did you alert the user of the sum?

Did you call your function at least twice?

 

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