Answers for "array reduce add object"

5

javascript reduce array of objects

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
Posted by: Guest on May-21-2020
0

how to push an object into an array in reducer

case ADD_CATEGORY_SUCCESS:
				return { ...state,categories:[...state.categories,action.payload] ,loading: true };
Posted by: Guest on June-01-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language