I'm trying to create a new object from values that have been passed in from a function, however, when I try to do so - I get the literal variable name put into state. For example:
updateReactions = (foods, reaction) => {
foods.forEach((food) => {
if (!this.state.reactions[food]) {
let newReaction = { food: { reaction : 1 } };
});
};
And if I call updateReactions(banana, happy), it'll create an object creating
{ food: { reaction : 1 } } ;
This outputs to a new object literally showing food: reaction: 1, but I would like for it to create
{ banana: { happy : 1 } }
Thank you!