Created
October 22, 2018 03:59
-
-
Save RikiyaOta/7b28ae085664196c71b6e904b0f68947 to your computer and use it in GitHub Desktop.
[javascript]reduceっぽい関数を書いてみる
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
function sumOfArray(arr, sum = 0){ | |
if(arr.lenth === 0) return sum; | |
else{ | |
const [first, ...rest] = arr; | |
return sumOfArray(rest, first + sum); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment