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 Practice forEach in JavaScript Practice forEach forEach Practice - 7

Vanessa Shing
Vanessa Shing
7,345 Points

Not sure why the program isn't accepting since when the work is checked, the output array looks correct

const months = ['january', 'february', 'march', 'april', 'may']; let capitalizedMonths = [];

months.forEach((month)=>{ let capitalizedMonth = (month[0].toUpperCase() + month.slice(1)) capitalizedMonths.push(capitalizedMonth) });

FEEDBACK: Bummer: Something's not right. Output of capitalizedMonths: ["January","February","March","April","May"]

app.js
const months = ['january', 'february', 'march', 'april', 'may'];
let capitalizedMonths = [];

months.forEach((month)=>{
let capitalizedMonth = (month[0].toUpperCase() + month.slice(1))
  capitalizedMonths.push(capitalizedMonth)
});

// capitalizedMonths should be: ['JANUARY', 'FEBRUARY', 'MARCH', 'APRIL', 'MAY']
// Write your code below

1 Answer

Steven Parker
Steven Parker
241,954 Points

To clarify what the instructions mean by "capitalize", see the comment provided at the end of the code that shows exactly what the result is expected to be.

But instead of capitalizing every letter, this code is only capitalizing the first letter of each word.