Last active
January 13, 2018 05:12
-
-
Save gchacaltana/2dde20ae45669f7f102e70a84c7f8d99 to your computer and use it in GitHub Desktop.
Ejemplo JS para devolver una excepción.
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 printError(message) { | |
throw new Error(message); | |
} | |
function validatePlayers(n) { | |
if (isNaN(n)) { | |
var message = "BooGame: Ingresa un valor númerico para la cantidad de jugadores."; | |
printError(message) | |
} | |
return true; | |
} | |
function start(n) { | |
if (validatePlayers(n)) { | |
console.log("BooGame: Cargando...."); | |
} | |
} | |
//Devuelve error | |
start("dos"); | |
//Forma correcta: start(2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment