'Coding Challenge #3'

Udemy Complete JavaScript Course

by trentHarlem

HTML

<h2>
Coding Challenge #3
</h2>

<p>
There are two gymnastics teams, Dolphins and Koalas. They compete against each other 3 times. The winner with the highest average score wins the a trophy!
</p>

<p>
1. Calculate the average score for each team, using the test data below<br>
2. Compare the team's average scores to determine the winner of the competition, and print it to the console. Don't forget that there can be a draw, so test for that as well (draw means they have the same average score).
</p>

<p>
3. BONUS 1: Include a requirement for a minimum score of 100. With this rule, a team only wins if it has a higher score than the other team, and the same time a score of at least 100 points. HINT: Use a logical operator to test for minimum score, as well as multiple else-if blocks πŸ˜‰<br>
4. BONUS 2: Minimum score also applies to a draw! So a draw only happens when both teams have the same score and both have a score greater or equal 100 points. Otherwise, no team wins the trophy.
</p>

<p>
TEST DATA: Dolphins score 96, 108 and 89. Koalas score 88, 91 and 110<br>
TEST DATA BONUS 1: Dolphins score 97, 112 and 101. Koalas score 109, 95 and 123<br>
TEST DATA BONUS 2: Dolphins score 97, 112 and 101. Koalas score 109, 95 and 106
</p>


GOOD LUCK πŸ˜€

CSS

html {
  font: 18px system-ui;
}

JavaScript

// TEST DATA:
// Dolphins score 96, 108 and 89. 
// Koalas score 88, 91 and 110

// challenge requires no functions or arrays.

//const dolphinAveScore = (96+108+89)/3;
//const koalasAveScore = (88+91+110)/3;

// BONUS 1 Data
const dolphinAveScore = (97+112+101)/3;
const koalasAveScore = (109+95+123)/3;

// BONUS 2 Data
//const dolphinAveScore = (97+112+101)/3;
//const koalasAveScore = (109+95+106)/3;

console.log('Dolphins av.', dolphinAveScore)
console.log('Koalas av.', koalasAveScore)



if (koalasAveScore > dolphinAveScore && koalasAveScore >= 100) {
console.log(`With an average score of ${koalasAveScore}, Koalas win the trophy! πŸ†`)
} else if (dolphinAveScore > koalasAveScore && dolphinAveScore >= 100) {
console.log(`With an average score of ${dolphinAveScore}, the Dolphins are the Winners! πŸ†`)
} else if (dolphinAveScore === koalasAveScore && dolphinAveScore >= 100 && koalasAveScore >= 100) {
console.log(`The competition is a Draw. Both teams win the trophy πŸ† πŸ†`)
} else {
  console.log('No one wins the trophy 😭');
}