-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalcAverage.js
More file actions
54 lines (46 loc) · 1.44 KB
/
calcAverage.js
File metadata and controls
54 lines (46 loc) · 1.44 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
50
51
52
53
54
// const calcAge = birthyear => 2017 - birthyear
// const age = calcAge(1991);
// console.log(age);
// const yearsUntilRetirement = birthYear => {
// const age = 2007 - birthYear;
// const retirement = 65 - age;
// return retirement;
// }
// console.log(yearsUntilRetirement(1997 ,1992, 1993));
const calcAverage = (s1, s2, s3) => (s1 + s2 + s3) / 3;
const dolphins = calcAverage(44,23,71);
const koalas = calcAverage(65,54,49);
// const dolphins = [44,23,71];
// const koalas = [65,54,49];
// const avgDolhins = () => {
// let avg = 0;
// let calcDolphins;
// for (let i = 0; i < dolphins.length; i++) {
// avg = avg + dolphins[i];
// }
// calcDolphins = avg / dolphins.length;
// return calcDolphins;
// }
// console.log(avgDolhins(dolphins));
// const dolh = avgDolhins(dolphins);
// const avgKoalas = () => {
// let avg = 0;
// let calcDKoalas;
// for (let i = 0; i < koalas.length; i++) {
// avg = avg + koalas[i];
// }
// calcDKoalas = avg / koalas.length;
// return calcDKoalas;
// }
// console.log(avgKoalas(koalas));
// const koal = avgKoalas(koalas);
const checkWinner = function (dolphins, koalas) {
if (dolphins >= 2 * koalas) {
console.log("Dolphins Wins !!!");
} else if (koalas >= 2 * dolphins) {
console.log("Koalas Wins !!!");
} else {
console.log("No team wins");
}
}
console.log(checkWinner(dolphins, koalas));