-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdy.js
25 lines (18 loc) · 1.83 KB
/
dy.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
//1. Create a variable named myAge and set it equal to your age as a number. Write a comment that explains this line of code.
// Variable for my age
const myAage = 30;
//2. Create a variable named earlyYears and save the value 2 to it. Note, the value saved to this variable will change. Write a comment that explains this line of code.
// Variable for first two years
let earlyYears = 2;
//3. Use the multiplication assignment operator to multiply the value saved to earlyYears by 10.5 and reassign to earlyYears.
earlyYears *= 10.5;
//4. Since we already accounted for the first two years, take the myAge variable , and subtract 2 from it. Set the result equal to a variable called laterYears. We’ll be changing this value later.
//takes age and subtracts 2
let laterYears = myAage - 2;
// 5.Multiply the laterYears variable by 4 to calculate the number of dog years accounted for by your later years. Use the multiplication assignment operator to multiply and assign in one step.
//Multiplying later years by 4
laterYears *= 4;
//6. If you’d like to check your work at this point, print earlyYears and laterYears to the console. Are the values that you expected?
//7. Add earlyYears and laterYears together, and store that in a variable named myAgeInDogYears .
//8. Let’s use a string method next. Write your name as a string. Call its built-in method .toLowerCase() ,and store the result in a variable called myName. The toLowerCase method returns a string with all lowercase letters.
//9.Write a console.log statement that displays your name and age in dog years. Use string interpolation to display the value in the following sentence:“My name is NAME. I am HUMAN AGE years old in human years which is DOG AGE years old in dog years.” Replace NAME with myName, HUMAN AGE with myAge, and DOG AGE with myAgeInDogYEars in the sentence above.