Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check if a variable is a number in javascript

// as test cases we have two variables of which 1 is a number and the second one is a string
let x = 7;
let y = "hello"
let result1 = !Number.isNaN(x) // true
let result2 = !Number.isNaN(y) // flase
 
PREVIOUS NEXT
Tagged: #check #variable #number #javascript
ADD COMMENT
Topic
Name
6+2 =