Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,624 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,624 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.