Write a JS function that will take an array as an argument and will calculate the sum of the numbers given in the array.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Write a JS function that will take an array as an argument and will calculate the sum of the numbers given in the array.

Post by answerhappygod »

Write a JS function that will take an array as an
argument and will calculate the sum of the numbers given in the
array. If the array is empty the sum should be zero. The result
should be printed in a div with an id of ‘divSum’. The array must
be inserted by the user once the page loads using
window.prompt.
Example sum([1,2,3]) //prints 6
sum([]) //prints 0
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply