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 trialIsaac Pfeif
11,437 PointsThere appears to be a problem with running object methods in the code challenge workspace.
In the current code challenge, (combine all the elements of an array into a list separated by commas and spaces and store it in a string). The solution (var list = months.join(", ");) is causing an error. I have run into this problem a few times before, but there was always a slight work-around, which is not present in this due to the requirements of the challenge.
var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
var list = 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
Chris Shaw
26,676 PointsHi Issac,
As per the challenge requirements, you need to join each array item into a comma and space separated string, you then need to log it to the console using console.log
.
console.log(months.join(", "));
Happy coding!
Isaac Pfeif
11,437 PointsThanks. Although I did finish the code challenge. In a previous attempt, the solution that I used (although slightly less efficient than that) was also getting the error. I had run into some other object related problems in previous code challenges such as using .length() in a previous array code challenge or using .toLowerCase() in the comparing strings code challenge, but it appears to have been fixed, since this challenge which required .join() didn't get the error.