Javascript Convert Integer property to String Property for all objects in an Array

If you use a map, you must return the modified object :

let customers = data.map( item => {
     item.id = String(item.id);
     return item;
});

But you don’t need a map. You can just iterate this way :

data.forEach(item => item.id = String(item.id)) // or "" + item.id, or item.id.toString()

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top