Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e9116b3

Browse files
author
programmiri
committed
Solve exercise resistor color duo
1 parent f63a556 commit e9116b3

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const colorMap = {
2+
black: 0,
3+
brown: 1,
4+
red: 2,
5+
orange: 3,
6+
yellow: 4,
7+
green: 5,
8+
blue: 6,
9+
violet: 7,
10+
grey: 8,
11+
white: 9,
12+
};
13+
14+
function value(colorNameList) {
15+
const accNumbers = colorNameList
16+
.map((colorName) => {
17+
return colorMap[colorName];
18+
})
19+
.join('');
20+
return parseInt(accNumbers);
21+
}
22+
23+
export { value };

‎resistor-color-duo/resistor-color-duo.spec.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ describe('Resistor Colors', () => {
55
expect(value(['brown', 'black'])).toEqual(10);
66
});
77

8-
xtest('Blue and grey', () => {
8+
test('Blue and grey', () => {
99
expect(value(['blue', 'grey'])).toEqual(68);
1010
});
1111

12-
xtest('Yellow and violet', () => {
12+
test('Yellow and violet', () => {
1313
expect(value(['yellow', 'violet'])).toEqual(47);
1414
});
1515

16-
xtest('Orange and orange', () => {
16+
test('Orange and orange', () => {
1717
expect(value(['orange', 'orange'])).toEqual(33);
1818
});
1919
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /