-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.js
71 lines (68 loc) · 2.42 KB
/
script.js
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
function calculate() {
const drinkExpense = document.getElementById("drinks").value * 6;
const diningExpense = document.getElementById("eatOut").value;
const socialExpense = document.getElementById("friends").value;
const busExpense = document.getElementById("bus").value * 5;
const newExpenses =
30 +
drinkExpense * 4 +
diningExpense * 4 +
socialExpense * 4 +
busExpense * 4;
const oldExpenses = 342;
const monthlyImprovement = oldExpenses - newExpenses;
if (monthlyImprovement > 0) {
document.getElementById(
"summary"
).innerHTML = `Congratulations! You helped Kate figure out her budget. She now has a monthly leftover of $${monthlyImprovement}! That's $${
monthlyImprovement - 8
} more savings per month!
She's now on track to buy her guitar before her audition!`;
} else {
document.getElementById(
"summary"
).innerHTML = `Oh no! Seems like you need to helped Kate figure out her budget again. She's not on track to buy her guitar before her audition!
Evaluate her expenses and find out where she can save!`;
}
}
function checkNeedsVsWants() {
var score = 0;
if (document.getElementById("starbucks-want").checked) {
document.getElementById("starbucks-score").innerHTML = "Correct";
score++;
} else {
document.getElementById("starbucks-score").innerHTML = "Incorrect";
}
if (document.getElementById("phone-need").checked) {
document.getElementById("phone-score").innerHTML = "Correct";
score++;
} else {
document.getElementById("phone-score").innerHTML = "Incorrect";
}
if (document.getElementById("car-want").checked) {
document.getElementById("car-score").innerHTML = "Correct";
score++;
} else {
document.getElementById("car-score").innerHTML = "Incorrect";
}
if (document.getElementById("bus-need").checked) {
document.getElementById("bus-score").innerHTML = "Correct";
score++;
} else {
document.getElementById("bus-score").innerHTML = "Incorrect";
}
if (document.getElementById("paint-want").checked) {
document.getElementById("paint-score").innerHTML = "Correct";
score++;
} else {
document.getElementById("paint-score").innerHTML = "Incorrect";
}
if (document.getElementById("restaurants-want").checked) {
document.getElementById("restaurants-score").innerHTML = "Correct";
score++;
} else {
document.getElementById("restaurants-score").innerHTML = "Incorrect";
}
document.getElementById("total-score").innerHTML = "Score: " + score + "/6";
return score;
}