+ 1
JS _ how do to check if an input includes numbers [0-9] ?
I used || to check if it includes 0 - 9. if (input.includes("1") || Input.includes("2") || Input.ncludes("3") || Input.includes("4") || .....) {x = true} ❓ Instead of listing them all like that, is there easier way to check if it includes 0-9 (number)?
5 odpowiedzi
+ 1
Ace i dont know what Regex is.
u know the actual answer?
0
if( number >= 0 && number <= 9)
{...}
I don't know where is the peoblem, why would you use regex? Why to complicate when you can do it on the right way
0
Dejan Francuz🥇 into a string (input), if the input includes or has "0", "1", ... "9", {do somethin}
0
Yes you can:
if(isNaN(variable) >= '0' && isNaN(variable) <= '9'){...}