I have been trying to summarize a list of two entries objects in a single one using the array's reduce method, but what I have in return is the value of one of the last entry. The code:
const swatches = [
{ emoji: "lion" , color: "#ff691f" },
{ emoji: "tiger" , color: "#fab81e" },
{ emoji: "fish" , color: "#7fdbb6" },
{ emoji: "frog" , color: "#19cf86" },
{ emoji: "pig" , color: "#f58ea8" },
{ emoji: "unicorn" , color: "#981ceb" },
{ emoji: "rabbit" , color: "#ffffff" },
{ emoji: "wolf" , color: "#000000" },
]
const animals = swatches.reduce( (emojis, entry) => emojis[entry.emoji] = entry.color, {} )