js高阶函数综合案例
一组数据,过滤出小于100的数,结果乘以2,并将结果汇总
<script>
let buf = [10, 110, 20, 120, 30, 130];
let resBuf = buf.filter(n => n < 100).map(n => n * 2).reduce((value, n) => value + n);
console.log(resBuf);
</script>
一组数据,过滤出小于100的数,结果乘以2,并将结果汇总
<script>
let buf = [10, 110, 20, 120, 30, 130];
let resBuf = buf.filter(n => n < 100).map(n => n * 2).reduce((value, n) => value + n);
console.log(resBuf);
</script>