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 d4d14b6

Browse files
author
programmiri
committed
Add modified solution for resistor color duo
1 parent 2306c93 commit d4d14b6

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ const colorMap = [
1111
'white',
1212
];
1313

14+
function getColorCode(name) {
15+
return colorMap.indexOf(name);
16+
}
17+
1418
function value(colorNameList) {
15-
const numAsString = colorNameList
16-
.reduce((acc, curr) => {
17-
acc.push(colorMap.indexOf(curr));
18-
return acc;
19-
}, [])
20-
.join('');
21-
return Number(numAsString);
19+
const colorCodes = colorNameList.map(getColorCode).join('');
20+
return Number(colorCodes);
2221
}
2322

2423
export { value };

0 commit comments

Comments
(0)

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