Hello.
I wanted to make a unit converter in JS but I stumbled across a problem with my if statement. The problem is that I wanted to make sure that whenever anything else than a number is entered, the result will be a string saying “please enter a number” but JS recognizes everything that is being typed as if it was a string.
if(typeof meter.value != 'number'){
km.innerText = "please enter a number"
} else {
km.innerText = meter.value / 1000}
And here’s the whole code: https://codepen.io/VeljkoCukic/pen/qBZNBJp