<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
const nums = [10, 20, 30, 40, 118]
/* let newNums = nums.filter(function(n) {
return n < 100
}) */
let newNums = nums.map(function(n) {
return n * 2
})
console.log(newNums)
let total = newNums.reduce(function(preValue, n) {
return preValue + n
}, 0)
console.log(total)
</script>
</body>
</html>
运行结果