Skip to content

Instantly share code, notes, and snippets.

@adedayojs
Last active January 21, 2020 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adedayojs/e184fb2b9af927653f141c46738c4ff4 to your computer and use it in GitHub Desktop.
Save adedayojs/e184fb2b9af927653f141c46738c4ff4 to your computer and use it in GitHub Desktop.
// This function allows you to sum all the numbers in a given array of numbers only
function sumNum(array){
// Check if the argument supplied is an array and not an empty array
return Array.isArray(array) && array.length > 0 ? array.reduce((a,b)=> (a + b)) : 'Argument supplied is not an array or an empty array'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment