JS Built-ins
← Array116 / 226
ArrayArray.prototype.joinintermediate

Array.prototype.join() β€” build an HTML list

πŸ“– Usage Example
const items = ['<li>one</li>', '<li>two</li>', '<li>three</li>']
items.join('\n')  // β†’ HTML list content joined with newlines

Use join() to assemble HTML snippets from an array of strings.

Array.prototype.join() β€” HTML generation

join() is handy for generating HTML markup by wrapping elements and joining them with a newline or other separator.

Challenge: Implement createList(items) that wraps each item in <li> tags and joins them with '\n'.

createList(['apples', 'bananas']) // β†’ '<li>apples</li>\n<li>bananas</li>'
πŸ’‘ Hints (2)
  • β€’ First `map` each item to `<li>item</li>`, then `join` the resulting array.
  • β€’ Template literals make it easy to wrap values: `` `<li>${item}</li>` ``.