21 lines
621 B
JavaScript
21 lines
621 B
JavaScript
const calcAvg = (team1, team2, team3) => (team1 + team2 + team3) / 3;
|
|
// DATA 1
|
|
// const avgDolphins = calcAvg(44, 23, 71);
|
|
// const avgKoalas = calcAvg(85, 54, 41);
|
|
|
|
// DATA 2
|
|
const avgDolphins = calcAvg(85, 54, 41);
|
|
const avgKoalas = calcAvg(23, 34, 27);
|
|
|
|
const checkWinner = function (avgDolphins, avgKoalas) {
|
|
if (avgDolphins >= 2 * avgKoalas) {
|
|
console.log(`Dolphins win (${avgDolphins} vs. ${avgKoalas})`);
|
|
} else if (avgKoalas >= 2 * avgDolphins) {
|
|
console.log(`Koalas win (${avgKoalas} vs. ${avgDolphins})`);
|
|
} else {
|
|
console.log("No team wins...");
|
|
}
|
|
};
|
|
|
|
checkWinner(avgDolphins, avgKoalas);
|