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 trial

JavaScript JavaScript Array Iteration Methods Array Manipulation Practice map()

Joel Greek
Joel Greek
4,421 Points

Bummer: 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.

app.js
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
Sean T. Unwin
28,690 Points

I'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);

Hi Joel, try the following:

abbreviatedDays = daysOfWeek.map(day => day.substr(0,3));
Joel Greek
Joel Greek
4,421 Points

Hey 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