Question:
I need a program that asks the user for a number and prints if it is a multiple of 5 or not.
So far I have done this:
let numero = parseInt(prompt("Ingrese un numero por favor: "));
if (numero % 5){
console.log("Si, el número "+numero+ " es múltiplo de 5");
}else{
console.log("No, el número "+numero+ " no es múltiplo de 5");
}
But it's not working.
Answer:
You need to make the comparison in your if
, that is: If the remainder of the division is ==
to zero
let numero = parseInt(prompt("Ingrese un numero por favor:")); //capturamos el valor if ( numero > 0 && numero % 5 == 0 ) { //hacemos la comparación console.log("Si, el número "+numero+ " es múltiplo de 5" ) }else{ console.log("No, el número "+numero+ " no es múltiplo de 5"); }