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

i've done it everyway possible. it still won't work.

i've tried with a space and a comma. before and after. i've tried it with just a space before the comma. nothing is working.

script.js
var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
var monthsString = months.join (' , ');
console.log (monthsString);
index.html
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Kim Dallas

You're close. Everything is syntactically correct, but if you have a look at the error message the Code Checker is giving, it will tell you exactly what is wrong:

Bummer: You must pass a string with a comma AND a space -- ', ' -- as the argument to the .join() method.

You are passing a space AND a comma AND a space. If you delete that first space the task will pass.

Nice work! :) :dizzy:

i've tried that Jason. I tried var monthsString = months.join (' ,'); console.log (monthsString); and it still won't work. it's driving me nuts. it's like it's stuck no matter what I do.

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

In your comment, you now have space and comma instead of comma and space.

The code does pass if you take the original code above and just delete the first space there:

var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
var monthsString = months.join (', ');
console.log (monthsString);

thank you. Jason. so the space has to be behind the comma.