Question: Write a JS function that will take an array as an argument and will calculate the avg of the numbers given in the array. If

 Write a JS function that will take an array as an

Write a JS function that will take an array as an argument and will calculate the avg of the numbers given in the array. If the array is empty the avg should be zero. The result should be printed in a div with an id of 'divAvg'. The array must be inserted by the user once the page loads using window.prompt. Example avg([1,2,3])// prints 26 avg([)// prints 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!