code

code


'use strict'

let sum = 0;

let userInput;

let count = 0;

let maxValue = Number.MIN_VALUE;

while(userInput !== null){

  userInput = prompt('Dear sir, would you pleaser enter a numer?');

  if(userInput === null){

    break;

  }

  if(Number.isNaN(Number(userInput)) || userInput === ''){

    alert('I must disagrre, this is not a number.');

  }else{

    sum += Number(userInput);

    count++;

    if(maxValue <= Number(userInput)){

      maxValue = Number(userInput);

    }

  }

}

alert(`The sum is ${sum} number of iterations is ${count} the max value is ${maxValue}`);


Report Page