Good evening!
I need to apply a loop for the user to always enter a number (via prompt), when typing 0 should appear an alert stating the number of numbers entered, not counting zero.
I'm not understanding what I'm doing wrong, as it is displaying an alert with all the numbers entered, including zero.
Does anyone know how I can do to count only the number of numbers excluding zero?
Thank you.
function TESTE2() {
var number = prompt("Enter a number, 0 to stop: ");
var result = 0;
while (number !== 0){
result = result+number;
number = +prompt("Enter another, chose 0 to stop");
}
while (number == 0){
alert("You entered "+ result+ " non-zero numbers!");
break;
}
}