How to design a javascript program that stores an array. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to design a javascript program that stores an array.

Write a javascript program that asks the user to enter up to 10 golf scores, which are to be stored in an array. You should provide a means for the user to terminate input prior to entering 10 scores. The program should display all the scores on one line and report the average score. Handle input, display, and the average calculation with three separate array processing functions.

12th Sep 2017, 2:18 PM
Masana Penny Baloyi
Masana Penny Baloyi - avatar
1 Answer
+ 1
var array = []; var in,x=1; alert("enter 10 scores"); //to store value while(array.length !=10){ in=parseInt(prompt(x)); array.push(in); x++; } //to print the array for(var i =0; i<array.length;i++){ document.write(array[i])); } Is that all?
13th Sep 2017, 3:09 AM
Victor_*
Victor_* - avatar