I'm having a hard time doing an exercise that asks for the following:
Using JavaScript, request a number in a prompt box, this number can not be greater than 50, if the number is larger, show an alert box to repeat the number. As a result, show all even numbers from 0 to the number entered, the total even numbers and the sum of these numbers (all numbers entered).
I'm at the beginning of JavaScript, so I do not know much yet. I did it. And the sum is not working, can anyone 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/>")