forked from HackYourFuture/Assignments
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathex2-dogYears.js
More file actions
32 lines (25 loc) · 1.22 KB
/
ex2-dogYears.js
File metadata and controls
32 lines (25 loc) · 1.22 KB
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
/*------------------------------------------------------------------------------
Full description at: https://github.com/HackYourFuture/Assignment/tree/main/1-JavaScript/Week3#exercise-2-dog-years
You know how old your dog is in human years, but what about dog years? Let's
calculate it!
1. Complete the function named `calculateDogAge`.
- It takes one parameter: your (fictional) puppy's age (number).
- Calculate your dog's age based on the conversion rate of 1 human year to
7 dog years.
- Return a string: "Your doggie is `age` years old in dog years!"
2. Use `console.log` to display the result of the function for three different
ages.
-----------------------------------------------------------------------------*/
export function calculateDogAge(humanAge){
const dogAge = humanAge * 7
return `Your doggie is ${dogAge} years old in dog years!`
}
function main() {
console.log(calculateDogAge(1)); // -> "Your doggie is 7 years old in dog years!"
console.log(calculateDogAge(2)); // -> "Your doggie is 14 years old in dog years!"
console.log(calculateDogAge(3)); // -> "Your doggie is 21 years old in dog years!"
}
// ! Do not change or remove the code below
if (process.env.NODE_ENV !== 'test') {
main();
}