How to use Object.key

What is wrong i am doing ?

const object1 = {
 1: {
        top: Math.floor(Math.random() * 100) + 20,
        left: Math.floor(Math.random() * 200) + 100,
        title: `Card G_${id}`
      },
  2: {
        top: Math.floor(Math.random() * 100) + 20,
        left: Math.floor(Math.random() * 200) + 100,
        title: `Card G_${id}`
      },
  3: {
        top: Math.floor(Math.random() * 100) + 20,
        left: Math.floor(Math.random() * 200) + 100,
        title: `Card G_${id}`
      },
  4: {
        top: Math.floor(Math.random() * 100) + 20,
        left: Math.floor(Math.random() * 200) + 100,
        title: `Card G_${id}`
      },
};

const newObj = {
...object1,
Object.keys(object1).map(key => {
                         if(object1[key]===1){
                         object1[key]["top"]=88;
                         object1[key]["left"]=88;
                      }
            return object[key];
            }
  )  


}
console.log(newObj)

I don’t know what it should do.

What’s happening, what should be happening instead?

I am trying to change top value and left value in the object1 object

1: {
        top: Math.floor(Math.random() * 100) + 20,
        left: Math.floor(Math.random() * 200) + 100,
        title: `Card G_${id}`
      },

So i am destructing it first then mapping it and changing the value.
Is there something wrong ?

There is a syntax error in the newObj

you can’t put Object.keys as a property, if you want that to be a property of the object you need to give a property name to it

Are you interested in getting an array of the object[key] elements?

using map to change stuff outside of it is not really a good thing to do, as it is causing side effects

I am interested in changing value of object[1][“Top”]
I am interested in changing value of object[1][“left”]

How can i do it without causing side effects ?

use forEach, map is to use if you are interested in the returned array