JavaScript – Create Ul and LI elements with JS (With chained function)

When you code in JS, there is always some time that you need to create some html list with JS from array or list or something else. I knew the trivial way with a simple for loop, but when I put myself a little deeper into JS, then I found a way to make it with a chained function. What is a chained function? Something that reminds me a lot to Python, but it is still JS. Thus, something like this – array.forEach(function(param){…}. 

Thus, if you have an array of elements as I have in the sample code, this is the expected result:


And this is how you obtain it:

If for any reason you need to locate my code in GitHub, you may click the link.

That is all! 🙂

Tagged with: