“in JavaScript reduzieren” Code-Antworten

Js Summe von Array

[1, 2, 3, 4].reduce((a, b) => a + b, 0)

// Output: 10
stdafx-h

wie man das Array mit Reduzierung in JavaScript verflacht

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

JavaScript -Summe des Arrays

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

JS reduzieren eine Reihe von Straße

var authors = [{name: 'some author'},{name: 'another author'},{name: 'last author'}]
var authorString = authors.map(function(author){
    return author.name;
}).join(",");
console.log(authorString);
Tough Tortoise

JavaScript reduzieren

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

in JavaScript reduzieren

// Reduce in javascript advance
// output: { '22': 2, '24': 2, '26': 1 }
const user = [
  {name:"Abhishek",age:24},
  {name:"Dhruval",age:22},
  {name:"Anish",age:26},
  {name:"Aakash",age:22},
  {name:"Darshil",age:24},
]
const newUser = user.reduce((acc,cur)=>{
  if(acc[cur.age]){
    acc[cur.age] = acc[cur.age] +1 
  }
  else{
    acc[cur.age] = 1 
  }
  return acc;
},{})

console.log(newUser)
Abhishek

Ähnliche Antworten wie “in JavaScript reduzieren”

Fragen ähnlich wie “in JavaScript reduzieren”

Weitere verwandte Antworten zu “in JavaScript reduzieren” auf JavaScript

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen