const arrayToHtmlList = (arr, listID) =>
        (el => (
          (el = document.querySelector('#' + listID)),
          (el.innerHTML += arr.map(item => `<li>${item}</li>`).join(''))
        ))();
      arrayToHtmlList(['item 1', 'item 2'], 'myListID');
      
      Javascript language logo

      Array to HTML list

      Convert array elements to HTML list

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.