Write JavaScript code to do the following:
• Prompt the user to enter numbers one at a time until they enter the number -999 (999 should not feature in the calculations below).
• Calculate the total of the numbers entered.
• Calculate the largest number entered (assume the largest possible number the user can enter is 999999).
• Calculate the lowest number entered (assume the smallest possible number the user can enter is -999999).
• Calculate the number of times a number is entered.
• Output the total, the number of times a user entered a number, the largest number, and the smallest number.
For example, if the user entered the numbers 10, 30, 20, -999, then the output would be:
Total of the numbers entered: 60
No of times the user entered a number: 3
The largest number entered: 30
The smallest number entered: 10.
Leave an answer