Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
Let's walkthrough the solution to the fifth code challenge.
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
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 upYou need to sign up for Treehouse in order to set up Workspace
Sign up