I get a json data and one of the values in it is a String that I want to convert to number. I am dealing with two dimensional array and I am having difficulties to access the value.
This is my json:
{
"products": [
{
"id": "AAA",
"description": "About AAA"
},
{
"id": "BBB",
"description": "about BBB",
"values": [
{
"name": "CustomerB",
"value": "1"
},
{
"name": "CustomerB",
"value": "3"
}
]
}
]
}
I need to convert value in values from String to number And here is how I try to use map
let newArray = products.map(product => {
product.values.map(item => {
...item, value: parseInt(item.value)
});
});
But newArray is always undefined. How can I convert a value, string to number in two dimensional array without changing anything else?