Created
January 3, 2016 19:58
-
-
Save MikeDigitize/605157a160bcb39c08a7 to your computer and use it in GitHub Desktop.
Some coding challenges for the AO front end team who are learning JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// write a function that returns the sum of two numbers | |
// then modify it to... | |
// return the sum of three numbers | |
// then the first argument is an array of numbers | |
// then the first argument may or may not be an array | |
// then there are an unknown amount of numbers and arrays passed in | |
function add(...nums) { | |
return nums.reduce((a,b) => a.concat(b), []).reduce((a,b) => a+b, 0); | |
} | |
add(5,4,[4,4,4,4,4,4,4,4,4,4,4,4],[10,10,10,10],3); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment