标签:document count let map head value func title console
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <body> <div id="app"> </div> </body> <script> let arr = [1,3,55,8]; // 需求:arr数组中的所有小于5的值翻倍并求和 let count = arr.filter(function(n){ return n < 5; }).map(function(n){ return n*2; }).reduce(function(preValue, n){ return preValue + n; },0); console.log(`和:${count}`); </script> </html>
标签:document count let map head value func title console
原文地址:https://www.cnblogs.com/cl94/p/12246887.html