Last active
March 13, 2023 23:46
-
-
Save beatrizsmerino/0fb7e1e69e14a2cf796e8e3bc8c97b0b to your computer and use it in GitHub Desktop.
Verify if it is a number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validation(num) { | |
if (num == "undefined" || num == null || num == "") { | |
console.log("Inserta un número."); | |
return 0; | |
} else { | |
if (isNaN(num) && num !== "") { | |
console.log("Ups... " + "'" + + num + "'" + " no es un número."); | |
return 1; | |
} else { | |
if (num % 1 == 0) { | |
console.log("'" + num + "'" + " es un numero entero."); | |
return 2; | |
} else { | |
console.log("'" + num + "'" + " es un numero decimal."); | |
return 3; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment