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
iterate over the percentages array and
store all of the percentages over 50 percent in the array upperRange.
Again I'll start with copying and pasting the code for
this challenge into atom in order to make it easier to read.
The solution to this challenge is similar to the previous challenge.
We need to evaluate the current value and
push that value on to the upperRange array if it satisfies our evaluation logic.
To start, I added the call to the forEach method.
Then I added the anonymous callback function.
I used percentage with the current value parameter name.
Then, I added an if statement to check if the current percentage is greater than 50.
if (percentage > 50).
And if the if statement evaluates to true,
I push the current percentage onto the upperRange array.
upperRange.push(percentage); and that's it.
On to the next challenge.
You need to sign up for Treehouse in order to download course files.Sign up