JSFiddle - React, Tailwind, and code Playground
JavaScript
var x = [{
"id": "id2",
"index": "2",
"str": "str2",
"cent": "200",
"triplet": "222"
},
{
"id": "id3",
"index": "3",
"str": "str3",
"cent": "300",
"triplet": "333"
},
{
"id": "id4",
"index": "4",
"str": "str4",
"cent": "400",
"triplet": "444"
},
{
"id": "id5",
"index": "5",
"str": "str5",
"cent": "500",
"triplet": "555"
}];
// Iterate thorugh the array
[].forEach.call(x, function(inst, i){
// Iterate through all the keys
[].forEach.call(Object.keys(inst), function(y){
// Check if string is Numerical string
if(!isNaN(x[i][y]))
//Convert to numerical value
x[i][y] = +x[i][y];
});
});
console.log(x);