mercredi 2 juin 2021

Different result of an if else on Javascript [duplicate]

I don't know why I keep getting the console.log from if statement even both averages are above 100. Where did I put my mistake?

const dolphinsScores = 97 + 112 + 101;
const dolphinsAverage = dolphinsScores / 3;

const koalasScores = 109 + 95 + 123;
const koalasAverage = koalasScores / 3;

console.log(dolphinsAverage);
console.log(koalasAverage);

if (dolphinsAverage || koalasAverage < 100) {
    console.log('One of the team is already lost')
} else if (dolphinsAverage > koalasAverage) {
    console.log('Team Dolphins are the winner of the competition! 🐬🎉');
} else if (koalasAverage > dolphinsAverage) {
    console.log('Team Koalas are the winner of the competition! 🐹🎉');
}

Aucun commentaire:

Enregistrer un commentaire