Skip to content

Instantly share code, notes, and snippets.

@JuliaGabellone
Created November 1, 2011 01:28
Show Gist options
  • Save JuliaGabellone/1329599 to your computer and use it in GitHub Desktop.
Save JuliaGabellone/1329599 to your computer and use it in GitHub Desktop.
function comparar (numero , string){
if (typeof(string)!= 'string' || typeof(numero)!='number'){
return false
}
if (isNaN(string)){
return false
}
if (numero == string){
console.log("Iguales")
return true
}
var resto = numero%string;
if (resto == 0){
console.log("Multiplo")
return true
}
else if (resto != 0){
console.log("No-multiplo")
return true
}
}
comparar(34 , "2")
@JuliaGabellone
Copy link
Author

Crear una funcion:

function comparar(numero, string)

Que:

  1. valide los parametros, el primero debe ser numerico el segundo un string CON UN NUMERO ADENTRO (ej: "12345" es correcto, "12A" no, "asdf" tampoco).

  2. comparar el 'numero' con el valor numérico del string.

2a) si son iguales imprimir en consola "IGUALES"

2b) si el 'string' es multiplo de 'numero' imprimir en consola "MULTIPLO"

2c) si no es multiplo imprimir en consola "NO-MULTIPLO"

  1. la función no debe devolver ningún valor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment