I have an array of objects:
csvContent = [{
"a": 123,
"b": "ccc"
},
{
"a": "bbb",
"b": "aaa"
}];
I process first "a" key value to a string use
for (let i in csvContent){
dataString.a = String(csvContent[i].a);
console.log(dataString.a);
}
But the result from the loop is:
result on first loop is
{
"a": "123",
"b": "ccc"
}
result on second loop is
{
"a": "bbb",
"b": "aaa"
}
How to make those separated object back to the beginning format:
[{},{}]
2
Answers
You can try using
Array.prototype.map()
Demo:
You dont have to create separate array and convert to string and then again push. Just do like this when value is string