Within my JSON object, I have price values in numerical format.
I am looking to convert these price values into strings within the same object
My approach involves using the map function:
var prods = [
{
"id": "id-1",
"price": 239000,
"info": "info-1"
},
{
"id": "id-2",
"price": 90770,
"info": "info-2"
},
{
"id": "id-3",
"price": 200787868,
"info": "info-3"
},
];
prods.map(function(a) {
a.price.toString()
.replace(/(\d)(?=(\d{3})+(\D|$))/g, '$1 ');
})
Although I expect the map function to modify my prods object, it remains unchanged.
I am curious about how to update the original object to meet my requirements.