Last active
December 3, 2020 22:07
-
-
Save danba340/b353da579019ed3698f71a675d809080 to your computer and use it in GitHub Desktop.
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 numbers = [1, 2, 3]; | |
const sum = numbers.reduce((acc, number) => { | |
console.log(acc, number); | |
return acc + number; | |
}, 0); | |
console.log(sum); | |
const multiplication = numbers.reduce((acc, number) => { | |
console.log(acc, number); | |
return acc + number; | |
}, 1); | |
console.log(multiplication); | |
const ingredients = ["π", "π", "π", "π"]; | |
const makeBananaBread = (ingredients) => { | |
return ingredients.reduce((acc, ingredient) => { | |
console.log(acc, ingredient) | |
if((acc + ingredient).includes("π") && (acc + ingredient).includes("π")) { | |
return "π₯§" | |
} | |
else if(ingredient === "π" || ingredient === "π"){ | |
return acc + ingredient; | |
} | |
return acc | |
}, "") | |
} | |
console.log(makeBananaBread(ingredients)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment