I have a incremental control in the UI that increase/decrease values by clicking left and right arrows. See the UI Image:
I'm trying to round a float returned by UI to two decimal points. It works most of the times but I get raw values once in a while. Here is the sample code"
input = document.getElementById("in");
input.addEventListener("input", function() {
console.log(input.value + " rounded : " + Math.round((input.value - 0.01) * 100) / 100);
});
<input id="in" type="number"></input>
Any thoughts?