-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrophy.js
More file actions
34 lines (31 loc) · 1.71 KB
/
trophy.js
File metadata and controls
34 lines (31 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Coding Challenge #3
// There are two gymnastics teams, Dolphins and Koalas. They compete against each
// other 3 times. The winner with the highest average score wins a trophy!
// Your tasks:
// 1. Calculate the average score for each team, using the test data below
// 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)
// 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 �
// 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
// Test data:
// § Data 1: Dolphins score 96, 108 and 89. Koalas score 88, 91 and 110
// § Data Bonus 1: Dolphins score 97, 112 and 101. Koalas score 109, 95 and 123
// § Data Bonus 2: Dolphins score 97, 112 and 101. Koalas score 109, 95 and 106
const dolphines = (97 + 112 + 101) / 3;
const koalas = (109 + 95 + 123) / 3;
if (dolphines > koalas && dolphines >= 100) {
console.log("Dolphines Team is the winner");
} else if (dolphines < koalas && koalas >= 100) {
console.log("Koalas Team is the Winner");
} else if (dolphines === koalas && dolphines >= 100 && koalas >= 100) {
console.log("Scores are level!, Both the team Won the Trophy");
} else {
console.log("No team wins the Trophy");
}
console.log(dolphines, koalas);