Write a JavaScript function to validate whether a given value is a number or not
In this article, we will write a JavaScript function to validate whether a given value is a number or not.
To validate a value, is a number or not , we will use the isNaN() method.
Demo : check if character is a number. #
function myFunction(e){
if(!isNaN(e)){
return 'Yes, this is a number'
}
else{
return 'No, this is not a number'
}
}
Try it Yourself »
The isNaN() method returns true if the value is not a number. If the value is a number , it returns false.
Example : isNaN() method. #
Try it Yourself »
save
listen
AI Answer
Write a JavaScript function to validate whether a given value is a number or not
0
In this article, we will write a JavaScript function to validate whether a given value is…
asked
Apu
0 answers
2915
In this article, we will write a JavaScript function to validate whether a given value is…
Answer Link
answered
Apu