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 trialpeterkorompis
10,823 PointsDo 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(' ');
1 Answer
Steven Parker
231,269 PointsApparently, 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.
Van Tran Huu
16,694 PointsVan Tran Huu
16,694 PointsI think we need both map() & join() in this case