lib/sugar.js
/*
  This function receives an array of objects. It should return a single object, which is a combination of all the objects in the array.
*/
This function receives an array of objects. It should return a single object, which is a combination of all the objects in the array.
This function receives an array of objects . It should return a single object which is a combination of all the objects in the array .
function addAll(arr) {
const objToArray = arr.map(array => Object.entries(array));
const flatArr = objToArray.reduce((acc, val) => acc.concat(val), []);
const newObj = Object.fromEntries(flatArr);
return newObj;
}
function addAll ( arr ) { const objToArray = arr . map ( array => Object . entries ( array ) ) ; const flatArr = objToArray . reduce ( ( acc , val ) => acc . concat ( val ) , [ ] ) ; const newObj = Object . fromEntries ( flatArr ) ; return newObj ; }
This function receives an array of objects.
This function receives an array of objects .