JSFiddle - React, Tailwind, and code Playground
by isuru_nan
JavaScript
function collectNumbers() {
let noOfInputs = 0;
let total = 0;
let largest = 999999;
let smallest = -999999;
let userInput;
while (true) {
userInput = parseInt(prompt("Enter a number (enter -999 to stop): "));
if (userInput === -999) {
break;
}
if (isNaN(userInput)) {
alert("Enter a valid number");
continue;
}
noOfInputs++;
total += userInput
if (userInput > largest) {
}
}
}