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 trialIan Hart
Full Stack JavaScript Techdegree Graduate 40,962 Pointsstuck on code challenge
I can't seem to figure out how to get my new array formed from map() into the let abbreviatedDays, any suggestions?
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
const abbr = daysOfWeek.map(day => day.substring(0,3));
2 Answers
Valeshan Naidoo
27,008 PointsI used slice instead of substring, it works.
Valeshan Naidoo
27,008 PointsSo you need to use the variable abbreviatedDays that was supplied,
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.slice(0,3));
Valeshan Naidoo
27,008 PointsIn line 2 you can see that let allows us to create an empty variable, we can re-write the variable empty variable to anything we want.
Ian Hart
Full Stack JavaScript Techdegree Graduate 40,962 PointsIan Hart
Full Stack JavaScript Techdegree Graduate 40,962 PointsI tried, that it still says "you haven't changed the variable value of abbreviatedDays yet."
Ian Hart
Full Stack JavaScript Techdegree Graduate 40,962 PointsIan Hart
Full Stack JavaScript Techdegree Graduate 40,962 PointsValeshan Naidoo How did you get the new array into the let variable abbreviatedDays?