Apply Prepend Functionality in Pure JS

// HTML Code

Test Website Print Prepend

    // JS Code

    Test Website Print Prepend
      // jshint esversion: 6

      window.onload = function (){
      let num = document.getElementById(“num”);
      let print = document.getElementById(“print”);
      let list = document.getElementById(“list”);
      let ppnd = document.getElementById(“pre”);

      print.onclick = function() {
      let val = num.value;
      let li = document.createElement(‘li’);
      li.innerText = val;
      let button = document.createElement(‘button’);
      button.innerText = ‘Clear’;
      list.appendChild(li);
      let up = document.createElement(‘button’);
      up.innerText = ‘Up’;
      let down = document.createElement(‘button’);
      down.innerText = ‘Down’;
      li.appendChild(button);
      li.appendChild(up);
      li.appendChild(down);
      button.onclick = function (e){
      e.target.parentElement.remove();
      };
      up.addEventListener(‘click’,function (e) {
      e.target.parentElement.parentElement.insertBefore(e.target.parentElement,e.target.parentElement.previousSibling);
      });
      down.addEventListener(‘click’, function (e) {
      e.target.parentElement.parentElement.insertBefore(e.target.parentElement.nextSibling,e.target.parentElement);
      });
      };

      ppnd.addEventListener(‘click’, function () {
      let val = num.value;
      let li = document.createElement(‘li’);
      li.innerText = val;
      let button = document.createElement(‘button’);
      button.innerText = ‘Clear’;
      // list.appendChild(li);
      let up = document.createElement(‘button’);
      up.innerText = ‘Up’;
      let down = document.createElement(‘button’);
      down.innerText = ‘Down’;
      li.appendChild(button);
      li.appendChild(up);
      li.appendChild(down);
      list.appendChild(li);
      let obj = document.getElementsByTagName(‘li’);
      console.log(obj);
      list.insertBefore(list.children[0],li);
      });
      };

      // I want to apply prepend when prepend button is pressed.

      and ppnd.addEventLinstener() is dealing the click event on prepend button

      please share files after uploading them on github, it would be much easier to get to the error from there

      I hope I’ve cleared your doubt. I ask you to please rate your experience here
      Your feedback is very important. It helps us improve our platform and hence provide you
      the learning experience you deserve.

      On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
      the doubt.