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
Write a JS function that will take an array as an argument and will calculate the sum of the numbers given in the array.
-
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.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!