Hey, I'm having some trouble in basics

for (let i = 0; i < 5; i++) {
  var msg = {
    execute: "Notify",
  };
  msg[`diff${i}`] = i;

}
  console.log(msg);

I don’t know why but it’s creating only one key & value pair but I actually want 5 pairs
. So please help me out

So you want something like this:

{ execute: 'Notify',
  diff0: 0,
  diff1: 1,
  diff2: 2,
  diff3: 3,
  diff4: 4 }

If so put msg outside your loop. Because right now it is making a new version on each loop. I would also recommend using let or const rather then var.

ohhh fudge that’s why senior devs always said “use lets and const instead of shity var”. I didn’t notice that msg is inside the loop and bcz of that new msg are popping up one by one