Snippet to convert array to HTML list items
This commit is contained in:
10
snippets/arrayToHtmlList.md
Normal file
10
snippets/arrayToHtmlList.md
Normal file
@ -0,0 +1,10 @@
|
||||
### arrayToHtmlList
|
||||
|
||||
Converts the given array elements into <li> tags and appends them to the list of the given id.
|
||||
|
||||
|
||||
```js
|
||||
const arrayToHtmlList = (arr, listID) =>arr.map(item =>document.querySelector("#"+listID).innerHTML+=`<li>${item}</li>`);
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user