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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![kris sistrunk](https://secure.gravatar.com/avatar/046281fd978ae20d432adabcdabb9460?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
kris sistrunk
1,953 Pointsnot sure on the final output
not sure what the challenge is looking for
var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
months.join
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Loops</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
2 Answers
![Unsubscribed User](https://uploads.teamtreehouse.com/production/profile-photos/9968522/micro_Profile.jpg)
Unsubscribed User
15,444 PointsSo this code challenge is asking you to replace the array in the months variable with a string using the join method. The string should include the months separated by a comma and a space, so we pass ', '
in as an argument of the join method. We then to print that string out to the console.
e.g:
var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
months = months.join(', ');
console.log(months);
It's probably not best practice to go replacing an whole array with a string, if this was a const variable, we'd get an error. Ideally, we would create a new variable when concatenating the months array. But hey, this is what the code challenge is asking for, so who am I to argue!
![Unsubscribed User](https://uploads.teamtreehouse.com/production/profile-photos/9968522/micro_Profile.jpg)
Unsubscribed User
15,444 PointsAhh so reading the task again, my initial thought on replacing the array was correct. It's not really clear in the instructions, but it actually wants you to create a new variable called final. Let's use const variables here to ensure that nothing is going to be replaced that we don't want to:
const months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
const final = months.join(', ');
console.log(final);
kris sistrunk
1,953 Pointskris sistrunk
1,953 PointsHi Berian,
Thanks. I tried the update and now I get this error:
TypeError: 'undefined' is not a function (evaluating 'months.join(", ")')
What do you think?
thanks