-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhumanyearstodog.html
More file actions
13 lines (13 loc) · 884 Bytes
/
Copy pathhumanyearstodog.html
File metadata and controls
13 lines (13 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
<script>
var myAge = prompt('Please enter your age');//variable defining my age
let earlyYears = 2;//let is used when the value will be changed
earlyYears *= 10.5;//multiplication assignment operator
let laterYears = myAge - 2;//Later years of dogs live
laterYears *= 4;//Using the multiplication assignment operator to multiply and assign in one step.
console.log(earlyYears);
console.log(laterYears);
var myAgeInDogYears = earlyYears + laterYears;//Adding both to get age in dog years.
var myName = prompt('Please enter your name').toLowerCase();//The toLowerCase method returns a string with all lowercase letters.
console.log(`My name is ${myName}.I am ${myAge} years old in human years which is ${myAgeInDogYears} years old in dog years`);
document.write(`My name is ${myName}.I am ${myAge} years old in human years which is ${myAgeInDogYears} years old in dog years`);
</script>