diff --git a/snippets/arrayToHtmlList.md b/snippets/arrayToHtmlList.md index 1122b9bc0..d62d28f40 100644 --- a/snippets/arrayToHtmlList.md +++ b/snippets/arrayToHtmlList.md @@ -5,16 +5,15 @@ tags: browser,array,intermediate Converts the given array elements into `
  • ` tags and appends them to the list of the given id. -Use `Array.prototype.map()`, `document.querySelector()`, and an anonymous inner closure to create a list of html tags. +Use `Array.prototype.map()` and `document.querySelector()` to create a list of html tags. ```js -const arrayToHtmlList = (arr, listID) => - (el => ( - (el = document.querySelector('#' + listID)), - (el.innerHTML += arr.map(item => `
  • ${item}
  • `).join('')) - ))(); +const arrayToHtmlList = (arr, listID) => + document.querySelector(`#${listID}`).innerHTML += arr + .map(item => `
  • ${item}
  • `) + .join(''); ``` ```js arrayToHtmlList(['item 1', 'item 2'], 'myListID'); -``` \ No newline at end of file +```