How do I return an array without square brackets?

Solution for How do I return an array without square brackets?
is Given Below:

I am using this code to add values to array but I am logging some extra square brackets.
I want this to get into Firebase as a map. Here are some code and log samples.

const [playgroundFilters, setPlaygroundFilters] = useState([{ id: 1 }]);

  const updateItem = (id, whichvalue, newvalue) => {
    var index = playgroundFilters.findIndex((x) => === id);

    let g = playgroundFilters[index];
    g[whichvalue] = newvalue;
    if (index === -1) {
      // handle error
      console.log('no match');
    } else
        ...playgroundFilters.slice(0, index),
        ...playgroundFilters.slice(index + 1),
onPress={(value) => updateItem(1, 'PG - Fenced', value)}
                  { label: 'No Fence', value: '' },
                  { label: 'Partially', value: 'Partially fenced' },
                  { label: 'Fully', value: 'Fully fenced' },

The code above logs this:

 LOG  [{"PG - Fenced": "Partially fenced", "id": 1}]

This shows up in firebase as a map within an array.
I want it to be showing up like this so that it just shows up in firebase as a map

{"PG - Fenced": "Partially fenced", "id": 1}

Converting it to a string and removing the square brackets just sends it as a string to Firebase instead of a map.

The initial state useState([{ id: 1 }]) is an array. The operations you are performing on it within setPlaygroundFilters will result in an array.

You should convert that to a map yourself. I’m not sure what kind of output you want so if you share that it’ll be easier to write a function for that.