-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathcatAndDogYears.js
More file actions
32 lines (24 loc) · 643 Bytes
/
catAndDogYears.js
File metadata and controls
32 lines (24 loc) · 643 Bytes
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
/*
I have a cat and a dog.
I got them at the same time as kitten/puppy. That was humanYears years ago.
Return their respective ages now as [humanYears,catYears,dogYears]
NOTES:
humanYears >= 1
humanYears are whole numbers only
Cat Years
15 cat years for first year
+9 cat years for second year
+4 cat years for each year after that
Dog Years
15 dog years for first year
+9 dog years for second year
+5 dog years for each year after that
*/
//Answer//
var humanYearsCatYearsDogYears = function(y) {
switch(y){
case 1: return [y,15,15]; break;
case 2: return [y, 24, 24]; break;
default: return [y, 24+((y-2)*4), 24+((y-2)*5)]
}
}