Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialoafwifkeiw
1,546 PointsI think this code should be accepted
Result is right and forEach IS used... :)
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
let noel = [];
// noel should be: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
// Write your code below
alphabet
.filter(letter => letter !== 'L')
.forEach(letter => noel.push(letter))
1 Answer
Matthew Long
28,407 PointsLooks good other than the missing semicolon. However, I think the challenge wants you to focus on .forEach()
so try something like:
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
let noel = [];
alphabet.forEach(letter => {
if (letter != "L") {
noel.push(letter);
}
});
You could always use the conditional operator if you want to stay clean like you had:
alphabet.forEach(letter => letter != "L" ? noel.push(letter) : null);