Created
March 11, 2020 12:41
-
-
Save borisd/a094a945bd358185f603c77900a83df7 to your computer and use it in GitHub Desktop.
Mini test
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
const arr = [1,2,3,4,6]; | |
const reduce = (arr, init, cb) => { | |
// TODO this! | |
} | |
// Mini test | |
const sum = reduce(arr, 0, (a, i) => a + i); | |
const mul = reduce(arr, 1, (a, i) => a * i); | |
const odd = reduce(arr, 0, (a, i) => a + (i % 2 ? 1 : 0)); | |
console.log(sum); | |
console.log(mul); | |
console.log(odd); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment