-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
51 lines (44 loc) · 1.77 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
$(".click").click(function() {
$(".results *").hide();
$(".results").show();
$("h2").show();
let first = $(".one").val();
let second = $(".two").val();
console.log(first);
console.log(second);
whatSnacker(first, second);
});
$(".two").change(function() {
let calories = $(".two").val();
if (calories >= 1000) {
$(".two").val(1000);
} else if (calories <= 100) {
$(".two").val(100);
}
});
function whatSnacker(flavor, calories) {
console.log(flavor, calories);
if (flavor === "" || calories === "") {
$(".results").text("Oops! There Was An Error. Try Again :/");
$("h2").hide("");
console.log("ok");
} else if (flavor === "spicy" && calories <= 300) {
$(".chap").show();
$("h2").text("You are an odd one since you chose " + flavor + " and " + calories + " calories. " + "You are chapulines!");
} else if (flavor === "spicy" && calories >= 300) {
$(".chips-apple").show();
$(".chips").show();
$(".apple").show();
$("h2").text("You are an odd one since you chose " + flavor + " and " + calories + " calories. " + "You are hot chapplesauce!");
} else if (flavor === "sweet" && calories <= 300) {
$(".cookies").show();
$("h2").text("You are like a baby one since you chose " + flavor + " and " + calories + " calories. " + "You are Gerber Puff!");
} else if (flavor === "sweet" && calories >= 300) {
$(".soda-gum").show();
$(".gum").show();
$(".soda").show();
$("h2").text("You are a sugar rush since you chose " + flavor + " and " + calories + " calories. " + "You are Gumda!");
} else {
$(".results").text("An Error Occured. You have to choose Spicy Or Sweet!");
}
}