Given an array of json objects, how do I convert values to each object in int or float?
var data = [{
"rank": "1",
"name": "Bill"
},
{
"rank": "2",
"name": "Ted"
},
{
"rank": "3",
"name": "John"
},
{
"rank": "4",
"name": "Jane"
}
]
The json objects I use are much larger in both dimensions, so I'm trying to figure out how I can use the map function to convert part of the "rank" from stringto int. There are other parts that I want to convert to floats, but now sorting by "grades" sorts 1,10,11,12,etc.
How can i do this? I am using React / ES6 / JSX / Babel or something similar.
source
share