-3

There is a json code. In it, you need to get "floatvalue" from each entry. I couldn't understand this note, please help me.

[
    {
        "iteminfo": {
            "a": "24726444009",
            "d": "162704505716002445",
            "floatvalue": 0.06065493822097778
        }
    },
    {
        "iteminfo": {
            "a": "24726350664",
            "d": "16595412847277410541",
            "floatvalue": 0.06316522508859634
        }
    }
]

1 Answers1

-1

You can use the Array#map function to extract the floatValue from each objcet

const arr = [
    {
        "iteminfo": {
            "a": "24726444009",
            "d": "162704505716002445",
            "floatvalue": 0.06065493822097778
        }
    },
    {
        "iteminfo": {
            "a": "24726350664",
            "d": "16595412847277410541",
            "floatvalue": 0.06316522508859634
        }
    }
]

const floatValues = arr.map(item => item.iteminfo.floatvalue)

console.log(floatValues)
RenaudC5
  • 3,553
  • 1
  • 11
  • 29