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() {

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

Help would be Appreciated. Thanks!


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';
  elem.dataset.lastValue = elem.value;
<input id="myInput" type="number" value="0">