From 39139e8749b114af8dfbc15c2399e24bd6d08b8d Mon Sep 17 00:00:00 2001 From: Arjun Mahishi Date: Tue, 19 Dec 2017 23:33:05 +0530 Subject: [PATCH 1/4] Snippet to convert array to HTML list items --- snippets/arrayToHtmlList.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 snippets/arrayToHtmlList.md diff --git a/snippets/arrayToHtmlList.md b/snippets/arrayToHtmlList.md new file mode 100644 index 000000000..a24b06b82 --- /dev/null +++ b/snippets/arrayToHtmlList.md @@ -0,0 +1,10 @@ +### arrayToHtmlList + +Converts the given array elements into
  • tags and appends them to the list of the given id. + + +```js +const arrayToHtmlList = (arr, listID) =>arr.map(item =>document.querySelector("#"+listID).innerHTML+=`
  • ${item}
  • `); + +``` + From ba78d837a113d1a447593c570b13e8fd5be583aa Mon Sep 17 00:00:00 2001 From: Arjun Mahishi Date: Tue, 19 Dec 2017 23:39:50 +0530 Subject: [PATCH 2/4] Fixed markdown typo --- snippets/arrayToHtmlList.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/arrayToHtmlList.md b/snippets/arrayToHtmlList.md index a24b06b82..ffa5b5aaa 100644 --- a/snippets/arrayToHtmlList.md +++ b/snippets/arrayToHtmlList.md @@ -1,6 +1,6 @@ ### arrayToHtmlList -Converts the given array elements into
  • tags and appends them to the list of the given id. +Converts the given array elements into 'li' tags and appends them to the list of the given id. ```js From 3a2af5cef815ffb8e520d438802b27e241d1a3fa Mon Sep 17 00:00:00 2001 From: Arjun Mahishi Date: Wed, 20 Dec 2017 10:11:58 +0530 Subject: [PATCH 3/4] Added space after arrow --- snippets/arrayToHtmlList.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/arrayToHtmlList.md b/snippets/arrayToHtmlList.md index ffa5b5aaa..7cc68081c 100644 --- a/snippets/arrayToHtmlList.md +++ b/snippets/arrayToHtmlList.md @@ -4,7 +4,7 @@ Converts the given array elements into 'li' tags and appends them to the list of ```js -const arrayToHtmlList = (arr, listID) =>arr.map(item =>document.querySelector("#"+listID).innerHTML+=`
  • ${item}
  • `); +const arrayToHtmlList = (arr, listID) => arr.map(item => document.querySelector("#"+listID).innerHTML+=`
  • ${item}
  • `); ``` From e30d3fe0cc56e3599439d173019c6d0c3c2ab9ba Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Wed, 20 Dec 2017 11:08:42 +0200 Subject: [PATCH 4/4] Update arrayToHtmlList.md --- snippets/arrayToHtmlList.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/arrayToHtmlList.md b/snippets/arrayToHtmlList.md index 7cc68081c..1dab3c778 100644 --- a/snippets/arrayToHtmlList.md +++ b/snippets/arrayToHtmlList.md @@ -1,10 +1,10 @@ ### arrayToHtmlList -Converts the given array elements into 'li' tags and appends them to the list of the given id. +Converts the given array elements into '
  • ' tags and appends them to the list of the given id. +Use `Array.map()` and `document.querySelector()` to create a list of html tags. ```js const arrayToHtmlList = (arr, listID) => arr.map(item => document.querySelector("#"+listID).innerHTML+=`
  • ${item}
  • `); - +// arrayToHtmlList(['item 1', 'item 2'],'myListID') ``` -