0

I have the following variable like so:

const uid = 1;
const name = 'New York';
const latitude = x;
const longitude = y;

I'm trying to create the following structure:

{ 1: { name: 'New York', latitude: x, longitude: y}}

So I can put it in a dictionary like so, where the keys are the uid:

cities: {
     1: {
          name: 'New York',
          latitude: x,
          longitude: y
         },
     2: {
          name: 'Copenhagen,
          latitude: x,
          longitude: y
        }
}

How do you do it? I've tried the following:

 const obj = { id { name, latitude, longitude }};
kingloui
  • 161
  • 3
  • 12

0 Answers0