exercism / exercism/javascript-analyzer

Improve resistor-color-duo: handle solutions based on reduce

オープン
#57 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
16
フォーク
21
平均マージ
6時間 53分
マージ済み PR(30日)
2

説明

Currently, when a solution contains `reduce`, we _explicitly_ bail out early. The following two examples should be considered _approvable_, but **not** optimal. Both should come with a hint.

```
const value = (colors) => {
return Number(
colors
.slice(0,2)
.reduce((digits, color) => digits + colorCode(color), '')
)
}
```
Use the type-juggling message hint.

```
function value(colors) {
return colors
.slice(0,2)
.reduce((value, color, index) => value + colorCode(color) * Math.pow(10, 1 - index), 0)
}
```
Use a new hint: Is `reduce` really the best candidate when trying to get the sum of significant digit values, when there are _two_ values only.

**Which exercise**

`resistor-color-duo`

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。