Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ejemplo JS para devolver una excepción.
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