exercism / exercism/javascript-analyzer

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

未关闭
#57 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
16
派生
21
平均合并
6 小时 53 分钟
30 天内合并 PR
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 摘要。