I have an Array of Objects something like this
[
{name: "John", country: "USA", revision: 1},
{name: "Mark", country: "England", revision: 0},
{name: "Bruce", country: "France", revision: 1}
]
I want to convert it into an object with key value pair with name key, like this
{
John : {name: "John", country: "USA", revision: 1},
Mark : {name: "Mark", country: "England", revision: 0},
Bruce : {name: "Bruce", country: "France", revision: 1}
}
This is what I have done but it does not seems to work
let component = contents.reduce(((content, current}) => {
content[name] = current;
return content;
}), {});
forloop should be enough to get the expected output.