Skip to content

Instantly share code, notes, and snippets.

@patmifsud
Last active September 27, 2021 22:45
Show Gist options
  • Save patmifsud/36a7a2647074258af9aa3e80191b41c4 to your computer and use it in GitHub Desktop.
Save patmifsud/36a7a2647074258af9aa3e80191b41c4 to your computer and use it in GitHub Desktop.
Sum of arrays

Sum of arrays

Write a function that receives two arguments, both of which are Arrays and sums them. These arrays contain only numbers. You don't know their length and they can contain both integers and floating point numbers.

Example

  [2, 6.4, 3] + [3, 3.6, 2] = 20

Bonus

Create another version of the above function that can accept more than two arrays as the arguments (you don't know the specific number of arguments). Hint - look up 'The arguments object'.

Bonus bonus

Create another version of the above function that can accept numbers, arrays or a combination of the two for any amount of arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment