0

I need to overwrite this javascript object every time it iterates

const emotions = {
  happy: '',
  neutral: '',
  sad: '',
  angry: '',
  fear: ''
}

Here "gestures" is iterated and I do destructuring of "emotion" and "score" and then overwrite the one that is changing but does not, it just adds a new method to the object

gestures.forEach(({emotion, score})=>{
   emotions.emotion = Math.trunc(100 * score)
 });
console.log(emotions);

enter image description here

What would be the best way to do it? Thanks in advance.

0 Answers0