我正在使用" prefer-arrow-method"使用下面的reduce函数抛出的eslint错误。我知道这是因为该函数是匿名的,但我如何重写reduce方法来解决此错误?
const nameBrand =
names.brand().reduce(function (sum, name) {
sum[name] = name;
return sum;
}, {});
答案 0 :(得分:2)
const nameBrand = names.brand().reduce((sum, name) => {
sum[name] = name;
return sum;
}, {});