“Kurangi contoh” Kode Jawaban

JavaScript mengurangi array objek

var objs = [
  {name: "Peter", age: 35},
  {name: "John", age: 27},
  {name: "Jake", age: 28}
];

objs.reduce(function(accumulator, currentValue) {
  return accumulator + currentValue.age;
}, 0); // 35 + 27 + 28 = 90
TC5550

Kurangi JavaScript

let array = [36, 25, 6, 15];
 
array.reduce((acc, curr) => acc + curr, 0)
// 36 + 25 + 6 + 15 = 82
Rick Oburu

JavaScript berkurang

var array = [36, 25, 6, 15];

array.reduce(function(accumulator, currentValue) {
  return accumulator + currentValue;
}, 0); // 36 + 25 + 6 + 15 = 82
TC5550

Sintaks Pengurangan di JS

[1,2,3,4,5].reduce((acc, current)=>acc+current, 0)
Healthy Hamster

mengurangi

var sum = _.reduce([1, 2, 3], function(memo, num){ return memo + num; }, 0);
=> 6
Yucky Yacare

Kurangi contoh

.reduce((acc, t) => [...acc, ...t], [])
Purple Team

Jawaban yang mirip dengan “Kurangi contoh”

Pertanyaan yang mirip dengan “Kurangi contoh”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya