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 trialEde Harrison
3,615 Pointsmap() with template literals in JavaScript
Hi there,
I'm doing the following challenge: https://teamtreehouse.com/library/javascript-array-iteration-methods/array-manipulation/practice-map
My code is not passing:
abbreviatedDays = daysOfWeek.map(day => `${day[0]}${day[1]}${day[2]}`);
I tested it elsewhere and it outputs the correct result, ['Sun', 'Mon', 'Tue', ... etc]
Any idea what I'm missing?
Thanks
const daysOfWeek = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
let abbreviatedDays;
// abbreviatedDays should be: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
// Write your code below
abbreviatedDays = daysOfWeek.map(day => `${day[0]}${day[1]}${day[2]}`);
1 Answer
Steven Parker
231,261 PointsApparently, this challenge doesn't allow template literals. Try using concatenation instead.
If you consider this a bug, you might want to report it to the Support folks.
Ede Harrison
3,615 PointsEde Harrison
3,615 PointsThanks. Concatenation did indeed work. With that being the case, I can't see why template literals wouldn't. Will shoot them a message