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 Displaying the Content

Do you need to use join() method to convert array of values to a string ?

Why don't you need to convert the options array into a string using the join method, like so:

select.innerHTML=options.join(' ');

I think we need both map() & join() in this case

1 Answer

Steven Parker
Steven Parker
231,275 Points

Apparently, assigning an array to "innerHTML" causes the system to perform type coercion to make it into a string. The default conversion adds comma separators, but they don't seem to be displayed in the select list on a typical browser.

I believe an explicit "join" with an empty string separator would be preferable even if not essential for creating the display. Perhaps it was omitted unintentionally.

Maybe if I tag him, Guil Hernandez will comment.