Answers for "js check var is not a number"

1

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
Posted by: Guest on June-01-2021
9

javascript check if variable is number

function isNumber(n) {
  return !isNaN(parseFloat(n)) && !isNaN(n - 0);
}
Posted by: Guest on May-22-2020

Code answers related to "js check var is not a number"

Code answers related to "Javascript"

Browse Popular Code Answers by Language