forked from benrbryant/JavaScript_Functions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
109 lines (84 loc) · 2.6 KB
/
app.js
File metadata and controls
109 lines (84 loc) · 2.6 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
console.log("Hello World!\n==========\n");
// Exercise 1 Section
// console.log("EXERCISE 1:\n==========\n");
// function printOdds(count) {
// for (let i = 1; i <= count; i++) {
// if (i % 2 != 0) {
// console.log(i);
// }
// }
// }
// printOdds(10);
// Exercise 2 Section
// function checkAge(age) {
// const aboveSixteen = "You can drive!";
// const belowSixteen = "Sorry, but you need to wait until you're 16.";
// if (age >= 16) {
// console.log(aboveSixteen);
// } else {
// console.log(belowSixteen);
// }
// }
// Exercise 3 Section
// function checkQuadrant(x, y) {
// if (x > 0 && y > 0) {
// return 1;
// } else if (x < 0 && y > 0) {
// return 2;
// } else if (x < 0 && y < 0) {
// return 3;
// } else if (x > 0 && y < 0) {
// return 4;
// } else if (x == 0 && y != 0) {
// return "x AXIS";
// } else if (x != 0 && y == 0) {
// return "y AXIS";
// } else {
// return "orgin";
// }
// }
// console.log(checkQuadrant(0, 2));
// console.log(checkQuadrant(1, 2));
// console.log(checkQuadrant(-6, 18));
// Exercise 4 Section
// function isValidTri(a, b, c) {
// return a + b > c && a + c > b && b + c > a
// }
// function checkTri(a, b, c) {
// let isValid = isValidTri(a, b, c,);
// if (isValid) {
// if ( a == b && b == c) {
// return `Equilateral`;
// } else if ( a == b || b == c || a == c) {
// } else {
// return `Scalene`;
// }
// } else {
// return `not valid`;
// }
// }
// console.log(checkTri(2, 3, 4)); //sc
// console.log(checkTri(2, 2, 2)); //wq
// console.log(checkTri(1, 2, 2)); //iso
// Exercise 5 Section
function dataUsageFeedback(planlimit, day, usage) {
let periodLength = 30;
let currentAvg = usage / day;
let projectedAvg = planlimit / periodLength;
let remainingData = planlimit - usage;
let remainingDays = periodLength - day;
let statusMsg;
let projectedUsage = remainingDays * currentAvg;
console.log(`${day} days used, ${remainingDays} days remaining`);
console.log(`daily average is ${projectedAvg} GB a day`);
if (currentAvg > projectedAvg) {
statusMsg = "Exceeding";
} else if (currentAvg < projectedAvg) {
statusMsg = "UNDER";
} else {
statusMsg = "AT";
}
console.log(`You are ${statusMsg} your daily average use ${currentAvg} GB a day. Continuing this usage will end up using ${planlimit - projectedUsage} from your data limit.`);
return statusMsg;
}
console.log(dataUsageFeedback(50, 12, 25));