JS turns all prompt input into a string. I'd like to test if it is an actual number and if yes, turn the type into a number. What's the best way to do it? If I use Number(target)
, it turns any string into a number
type too.
var res = prompt('How long'); //input: "ABC"
typeof Number(res)
>> "number"