-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.js
33 lines (24 loc) · 1.36 KB
/
variables.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
//javascript-phase-1-blackrose9
function ageCalculator() { //declares a function
var thisYear = 2019; //this code declares the variable 'thisYear' and assigns the value '2019' to it.
var birthYear = 1996;
var futureYear = 2066;
var possibleage1; //declares a variable
var possibleage2;
possibleage1 = futureYear - birthYear; //assigns value to variable
possibleage2 = futureYear - thisYear;
console.log("First possible age is " + possibleage1); //outputs to the console
console.log("Second possible age is " + possibleage2);
}
function foodCalculator(){
var currentAge = 22; //declares a variable and assigns a value to it
var maxAge = 66;
var wingsPerDay = 24;
//the code below declares a variable, assigns an expression which calculates a value
var wingsPerYear = wingsPerDay * 365; //multiplies wingsPerDay by 365 days in a year
var totalwingcount = (maxAge - currentAge) * wingsPerYear; //calculates the total wings eaten from now till maxAge
//outputs to the console
console.log("You will need " + " " + totalwingcount + " " + "to last you until the ripe old age of" + " " + maxAge);
//outputs to HTML element with ID = 'outputq2'
document.getElementById("outputq2").innerHTML = ("You will need " + " " + totalwingcount + " " + "to last you until the ripe old age of" + " " + maxAge);
}