-
Notifications
You must be signed in to change notification settings - Fork 135
/
snackCalculator.js
49 lines (22 loc) · 1.53 KB
/
snackCalculator.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
let ageInput = document.querySelector(".ageInput");
let numInput = document.querySelector(".numInput");
let clearButton = document.querySelector(".clear");
let equalsButton = document.querySelector(".equals");
let result = document.querySelector(".result");
// 1. Create an arrow function called calculateSupply with two parameters. One called age and the other numPerDay.
{
// 2. Declare a maxAge variable and set it equal to 100.
// 3. Declare a totalNeeded variable and set it equal to the numPerDay parameter multiplied by 365 and then that amount is multiplied by the maxAge variable - the age parameter.
// 4. Update the result div's inner html to show the total needed and max age. Use string interpolation to create the message: "You will need _________ cups of tea to last until the ripe old age of ___________!"
}
equalsButton.addEventListener("click", () => {
// 5. Declare an userAgeInput variable and set it equal to the value of the ageInput. This needs to be a number, not a string! Be sure to place that inside our Number() method!
// 6. Declare a userNumInput variable and set it equal to the value of the numInput. This needs to be a number, not a string! Be sure to place that inside our Number() method!
// 7. Call the calculateSupply function. Be sure to include the userAgeInput variable and the userNumInput variable as the two parameters!
})
//Do Not Touch This Code
clearButton.onclick = function() {
ageInput.value = "";
numInput.value = "";
result.innerHTML = "";
}