-1
I’m having trouble doing an exercise that asks for the following:
Using Javascript, ask for a number in a prompt box, this number cannot be higher than 50, if the number is higher, show an alert box to repeat the number. As a result, show all even numbers from 0 to the number given, the total even numbers and the sum of these numbers (all numbers typed).
I’m at the beginning of Javascript, so I don’t know much yet. I managed to do this. And the sum is not working, someone can give me a light on the rest?
document.write("EXERCÍCIO 13" + "<br/>" + "<br/>");
var num, par, contPar = 0, soma = 0;
num = prompt("Digite um número: ");
parseInt(num)
parseInt(soma)
soma = num
while (num != 0 || num > 50) {
num = prompt("Digite um número abaixo de 50 ou 0 para finalizar:");
soma = soma + num
if (num % 2 == 0)
contPar = contPar + 1
}
document.write("Quantidade de números Pares digitados: " + contPar + "<br/>" + "<br/>")
document.write("Soma dos números digitados: " + soma + "<br/>" + "<br/>")
Now it was clear, thank you very much!! And it worked, thanks very much! D
– Lucas Oliveira