Home > Enterprise >  How To assign same value To Each element of array in react native. How to Make key pair array in rea
How To assign same value To Each element of array in react native. How to Make key pair array in rea

Time:10-01

I Have Array data Like this

Subcategories:["Wooden Furniture","Office Furniture","Kitchen Furniture","Modular Office Furniture","Industrial Furniture","Steel Furniture","Living Room Furniture","|Storage and Display Furniture","Entryway Furniture","Inflatable Furniture","Patio Furniture & Accessories","Storage and Display Furniture"," Office & Commercial Furniture "]

Now I want To Assign same Key To each Element In it. Basically I want To Make Key Pair Value. please help . thanks

CodePudding user response:

You can use Array.prototype.map.

const directories = Subcategories.map(sub => {
  return { your_keyname: sub }
})
  • Related