Page 1 of 1

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

Posted: Sun May 15, 2022 2:00 pm
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