38 lines
979 B
JavaScript

const prices = [20, 25, 30, 45, 50, 90, 15];
const result = prices.reduce((acc, curr) => {
if (curr > 30) {
acc++;
}
return acc;
}, 0);
console.log(result)
const players = [
{ player: "yoshi", score: 50 },
{ player: "mario", score: 30 },
{ player: "david", score: 18 },
{ player: "mario", score: 99 },
{ player: "yoshi", score: 50 },
{ player: "mario", score: 90 },
{ player: "mario", score: 30 },
{ player: "yoshi", score: 77 },
{ player: "mario", score: 90 },
{ player: "david", score: 23 },
{ player: "david", score: 10 },
{ player: "mario", score: 24 },
{ player: "mario", score: 90 },
{ player: "yoshi", score: 17 },
{ player: "mario", score: 30 },
{ player: "david", score: 10 }
];
const marioTotal = players.reduce((acc, curr) => {
if (curr.player === "mario") {
acc += curr.score;
}
return acc;
}, 0);
console.log(marioTotal)