Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Let's walkthrough the solution to the fifth code challenge.
In this challenge we need to use the forEach method to 0:00 iterate over the percentages array and 0:03 store all of the percentages over 50 percent in the array upperRange. 0:05 Again I'll start with copying and pasting the code for 0:11 this challenge into atom in order to make it easier to read. 0:14 The solution to this challenge is similar to the previous challenge. 0:21 We need to evaluate the current value and 0:24 push that value on to the upperRange array if it satisfies our evaluation logic. 0:27 To start, I added the call to the forEach method. 0:32 So percentages.forEach. 0:36 Then I added the anonymous callback function. 0:39 I used percentage with the current value parameter name. 0:42 Then, I added an if statement to check if the current percentage is greater than 50. 0:49 if (percentage > 50). 0:54 And if the if statement evaluates to true, 0:59 I push the current percentage onto the upperRange array. 1:02 upperRange.push(percentage); and that's it. 1:06 On to the next challenge. 1:12
You need to sign up for Treehouse in order to download course files.Sign up