DEV Community

Discussion on: 10 Interview Questions for Javascript Developer

Collapse
 
omarkhatibco profile image
Omar Khatib

8) Write a code to format the array1 into array2

you could use array.reduce to solve it, like this

const array2 = array1.reduce((obj,{key,value})=>{
obj[key] = value;
return obj;
},{});