Created
August 27, 2019 19:46
-
-
Save ralfting/5843914248b91aa074e6e6ed9bde5af5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function() { | |
| 'use strict'; | |
| const $textBuildList = $('.build-list-js > p'); | |
| const templateLi = text => `<li>${text}</li>`; | |
| const stringToArray = paragraph => paragraph.split('\n'); | |
| $textBuildList.each(function textToList(index, text) { | |
| const arrText = stringToArray(text.innerText); | |
| let listHtml = ""; | |
| arrText.forEach(function appendInTheList(text) { | |
| if(text === "") return; | |
| const textWithTemplate = templateLi(text); | |
| listHtml = listHtml.concat(textWithTemplate); | |
| }); | |
| $textBuildList.innerHTML = ''; | |
| $textBuildList[index].innerHTML = listHtml; | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment