Skip to content

Instantly share code, notes, and snippets.

@chaw-bot
Last active February 18, 2022 21:45
Show Gist options
  • Save chaw-bot/4072068608cfe576048c0b20404bf721 to your computer and use it in GitHub Desktop.
Save chaw-bot/4072068608cfe576048c0b20404bf721 to your computer and use it in GitHub Desktop.
Given an array of integers, find the sum of its elements. For example, if the array , , so return . Function Description Complete the simpleArraySum function in the editor below. It must return the sum of the array elements as an integer. simpleArraySum has the following parameter(s): ar: an array of integers Input Format The first line contains…
function simpleArraySum(ar) {
let sum = 0
ar.map((num) => {
sum += num;
});
return sum;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment