Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
How to rename array keys to a string value in JavaScript

I have an array that conatins a list of objects, then am mapping through the object to display a list of data. Right now when user add item to the list , I want to change the index of that newly added Item to a string value.

What am getting is this

 [{…}]
0: {categories: 'A very nice shawarma for 2!', discount: 0, id: 7,}

Instead what I want is the index key 0 of the array to change to a string value rather than the automatic 0, 2,3... inedex key base

Something like ...

"String" : {categories: 'A very nice shawarma for 2!', discount: 0, id: 7,}
about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!