Published
- 1 min read
typescript check if string is number
The solution for this is noted below
typescript check if string is number
Solution
let numberToCheck: string = "40";
if(!isNaN(Number(numberToCheck))) {
console.log("string is a number")
}
else {
console.log("string is NOT a number")
}
Try other methods by searching on the site. That is if this doesn’t work