Check if Input Value has Decreased/Increased

I have an Input which is of type number and want to check if its value has Decreased/Increased:

document.getElementById("myInput").addEventListener("change", function() {
    console.log(document.getElementById("myInput").value)

    // Check if Value has Increased/Decreased here
});
<input id="myInput" type = "number" value = "0">

Help would be Appreciated. Thanks!

Answer

Store the value and compare it

var elem = document.getElementById("myInput");
elem.dataset.lastValue = elem.value;
elem.addEventListener("change", function() {

  const direction = +elem.value > +elem.dataset.lastValue ? 'increased' : 'decreased';
  console.log(direction);
  elem.dataset.lastValue = elem.value;
});
<input id="myInput" type="number" value="0">