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

Brandi Apetsi
Brandi Apetsi
4,810 Points

Question about line 45 of Practice Template Literals solution

I understand everything except the .join('') on line 45. Can you explain what is being joined?

1 Answer

kevinardo
seal-mask
.a{fill-rule:evenodd;}techdegree
kevinardo
Treehouse Project Reviewer

Hi Brandi!

Because map() method returns an array, the two planets that get created by createPlanetHTML(planet) inside .map() are then returned as an array, and that array is then presented to us with document.querySelector('body').innerHTML

If you play around a bit and remove the .join(''), you can see the comma ( , ) in the browser, right after the first planet. You can try and write other stuff as a string inside of .join() method. Anyhow, .join() is used here to join the two arrays and leave nothing between them, therefore the empty string in the method.

If you want to dive deeper, check out the methods on MDN: Link to.map() Link to .join()

I hope this helped! Have a great day /Kevin