Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
Let's walkthrough the solution to the fourth code challenge.
-
0:00
For this challenge, we need to use the forEach method to iterate over
-
0:04
the alphabet array, which contains each of the letters in the alphabet, and
-
0:08
store each letter in the array noel except for the L character.
-
0:12
Let's start with copying and pasting the code for
-
0:15
this challenge into Atom in order to make the code easier to read.
-
0:21
To solve this challenge, I added the call to forEach method with anonymous call
-
0:26
back function using arrow function syntax.
-
0:29
So alphabet.forEach.
-
0:32
I used character for the current value parameter name.
-
0:38
And I included a set of curly braces to define a code block.
-
0:42
Then I added an if statement to ensure that the current character wasn't
-
0:46
the letter L.
-
0:47
So, if (character
-
0:52
!== 'L'.
-
0:56
And if the if statement evaluates the true,
-
0:59
I push the current character onto the noel array.
-
1:02
So noel.push(character);.
-
1:06
And that's my solution.
-
1:08
We'll see you after the next challenge.
You need to sign up for Treehouse in order to download course files.
Sign up