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 Loops, Arrays and Objects Tracking Multiple Items with Arrays Using Array Methods

Is this exercise broken? I have joined all the strings and have done the console.log(months.pop())method

var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];

months.join(', '); console.log(months.pop())

Is not working

var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];

months.join(', ');
<!DOCTYPE html>
  <meta charset="utf-8">
  <title>JavaScript Loops</title>
<script src="script.js"></script>

3 Answers

Hey David,

You're very close. Try creating a new variable to store the combined months in. Something like:

var combinedMonths = months.join(', ');

Then log that to the console.

Part of the reason you want to do this to preserve the array of months, while creating a new variable that holds the months in a single string.

Hope that helps! Let me/us in the Treehouse community know if you need more help! πŸ™Œ


Why are you using months.pop()? You are just supposed to log the string.

Hi there, thanks for your answers. I think I didn't read well the instructions. Sorry for the inconvenience.

No inconvenience at all! That's what the community here is for.