“Kurangi di JS” Kode Jawaban

cara meratakan array dengan pengurangan javascript

let flattened = [[0, 1], [2, 3], [4, 5]].reduce(
  function(accumulator, currentValue) {
    return accumulator.concat(currentValue)
  },
  []
)
// flattened is [0, 1, 2, 3, 4, 5]
Helpless Hamster

jumlah array javascript

const sum = arr => arr.reduce((a, b) => a + b, 0);
Batman

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 Jumlah Nilai Array

function getArraySum(a){
    var total=0;
    for(var i in a) { 
        total += a[i];
    }
    return total;
}

var payChecks = [123,155,134, 205, 105]; 
var weeklyPay= getArraySum(payChecks); //sums up to 722
Grepper

Kurangi di JS

var totalYears = pilots.reduce(function (accumulator, pilot) {
  return accumulator + pilot.years;
}, 0);
Ahmad Mustafeen

Jawaban yang mirip dengan “Kurangi di JS”

Pertanyaan yang mirip dengan “Kurangi di JS”

Lebih banyak jawaban terkait untuk “Kurangi di JS” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya