-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchallenge2.js
More file actions
49 lines (44 loc) · 1.66 KB
/
Copy pathchallenge2.js
File metadata and controls
49 lines (44 loc) · 1.66 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var johnGame1 = 150;
var johnGame2 = 120;
var johnGame3 = 103;
var mikeGame1 = 150;
var mikeGame2 = 120;
var mikeGame3 = 103;
var maryGame1 = 150;
var maryGame2 = 120;
var maryGame3 = 103;
var johnAVG = (johnGame1 + johnGame2 + johnGame3)/3;
var mikeAVG = (mikeGame1 + mikeGame2 + mikeGame3)/3;
var maryAVG = (maryGame1 + maryGame2 + maryGame3)/3;
/*
if (johnAVG === mikeAVG) {
console.log("The averages are equal.");
} else if (johnAVG > mikeAVG){
console.log("John's team has the best average at " + johnAVG + " points per game.");
} else {
console.log("Mike's team has the best average at " + mikeAVG + " points per game.");
}
*/
switch (true){
case (johnAVG === mikeAVG && maryAVG === mikeAVG):
console.log("The averages are equal at " + johnAVG + " points per game.");
break;
case (johnAVG > mikeAVG && johnAVG > maryAVG):
console.log("John's team has the best average at " + johnAVG + " points per game.");
break;
case (mikeAVG > johnAVG && mikeAVG > maryAVG):
console.log("Mike's team has the best average at " + mikeAVG + " points per game.");
break;
case (maryAVG > mikeAVG && maryAVG > johnAVG):
console.log("Mary's team has the best average at " + maryAVG + " points per game.");
break;
case (johnAVG === mikeAVG && johnAVG > maryAVG):
console.log("John's and Mike's teams tie for best average at " + johnAVG + " points per game.");
break;
case (mikeAVG === maryAVG && mikeAVG > johnAVG):
console.log("Mike's and Mary's teams tie for best average at " + mikeAVG + " points per game.");
break;
case (maryAVG === johnAVG && maryAVG > mikeAVG):
console.log("Mary's and John's teams tie for best average at " + maryAVG + " points per game.");
break;
}