Ensure input to be an integer: decimals are dropped (1.9 and "1.9" both give 1), never rounded. Non numeric input gives NaN, as with parseInt.
1.9
"1.9"
1
NaN
parseInt
Ensure input to be an integer: decimals are dropped (
1.9and"1.9"both give1), never rounded. Non numeric input givesNaN, as withparseInt.