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 trialJoel Greek
4,421 PointsBummer: Line 7: Unexpected token ILLEGAL in slice solution.
I am getting this code to work in my code editor (vscode) but I get: "Bummer: Line 7: Unexpected token ILLEGAL in slice solution." when I'm doing the challenge.
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(days => `${days.slice(0, 3)}`);
2 Answers
Sean T. Unwin
28,690 PointsI'm not sure why it doesn't work in the Challenge, but, really, there is no need for the template literal as it's redundant and we're not adding any extra text.
Remove the template literal and placeholder syntax so you end up with, days.slice(0, 3)
;
Shaun Kelly
35,560 PointsHi Joel, try the following:
abbreviatedDays = daysOfWeek.map(day => day.substr(0,3));
Joel Greek
4,421 PointsHey Shaun, thanks! But I really wasn't looking for a complete solution. I managed to complete the task, but I was just curious to why my code didn't work. Cheers / Joel
Joel Greek
4,421 PointsJoel Greek
4,421 PointsThat's a good point, cheers!
Sean T. Unwin
28,690 PointsSean T. Unwin
28,690 PointsCheers!