From fd008df60a222c07e9e36b506911bf34fb3bb4c7 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 f9174c38fae061ccc47e9ffcb14b6b19d5eface3 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 91d306877020dd07049d72ec2304b172d05ee5c9 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 c6d1e63bfd1089aca3d837648c76106beccd2fc8 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') ``` -