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 trialterry okey
3,187 PointsAssigning a "joined" string to a new var?
I have extensive notes but no mention of how to join arrays and then console.log them? Need new variable?
terry okey
3,187 PointsEven the Mozilla DN page has no info on how to access a newly joined string?
1 Answer
terry okey
3,187 PointsSorry I found the answer finally on MDN. i was not expecting to put the join method right inside the console statement. I am still thinking in one move at a time.
const planets = ['Earth','Mars','Saturn','Mecury','Jupiter','Venus','Uranus','Neptune']; console.log(planets.join(', '));
Tom Lamb
9,472 PointsYou can also
const planets = ['Earth','Mars','Saturn','Mecury','Jupiter','Venus','Uranus','Neptune'].join(', ');
console.log(planets);
terry okey
3,187 Pointsterry okey
3,187 PointsI have this code but it says it is not logging the new string to the console?
const planets = ['Earth','Mars','Saturn','Mecury','Jupiter','Venus','Uranus','Neptune']; planets.join(', ') ; console.log(planets);