function Ejercicio5() {
for (let i = 1; i <= 450; i++) {
if (i % 5 == 0) {
}
document.querySelector("#pResultado5").innerHTML += i + " ";
}
}
I need to display numbers between 1 and 450 that are multiples of 5 on button press. I created my code, it works but it only shows me the numbers between 1 and 450 but not the multiples of 5. I need help, thanks!
To know if it is a multiple of 5, I personally consider that it must also be divisible by 5: EYE that goes inside the IF your condition... not Outside.
as you can see I use the module operator
%
and validate that the result is identical===
to0
the previous case using awhile
you can also do it with afor
implementation: