Skip to content

Commit c2ec087

Browse files
committed
ex-1: delegate call to plumage to Bird.plumage
1 parent 8b304cb commit c2ec087

File tree

1 file changed

+3
-10
lines changed
  • src/functions-into-class-hierarchy

1 file changed

+3
-10
lines changed

src/functions-into-class-hierarchy/index.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Bird } from './bird';
2+
13
export function plumages(birds) {
24
return new Map(birds.map(b => [b.name, plumage(b)]));
35
}
@@ -7,16 +9,7 @@ export function speeds(birds) {
79
}
810

911
export function plumage(bird) {
10-
switch (bird.type) {
11-
case 'EuropeanSwallow':
12-
return 'average';
13-
case 'AfricanSwallow':
14-
return bird.numberOfCoconuts > 2 ? 'tired' : 'average';
15-
case 'NorwegianBlueParrot':
16-
return bird.voltage > 100 ? 'scorched' : 'beautiful';
17-
default:
18-
return 'unknown';
19-
}
12+
return new Bird(bird).plumage;
2013
}
2114

2215
export function airSpeedVelocity(bird) {

0 commit comments

Comments
 (0)