Loop object that in the array and in the another object

后端 未结 2 1793
鱼传尺愫
鱼传尺愫 2021-01-25 20:49

i have the following structure. I need to get Internal value and through in the React. I think i need to get an array of values, for example: [\'Bitcoin\', \'Etherium\'...] and

2条回答
  •  一整个雨季
    2021-01-25 21:19

    Here's how you'd get an array of coin names using Array.prototype.map()

    const arr = [{
        "CoinInfo": {
          "Id": "1182",
          "Name": "BTC",
          "FullName": "Bitcoin",
          "Internal": "BTC",
          "ImageUrl": "/media/19633/btc.png",
          "Url": "/coins/btc/overview"
        }
      },
      {
        "CoinInfo": {
          "Id": "7605",
          "Name": "ETH",
          "FullName": "Ethereum",
          "Internal": "ETH",
          "ImageUrl": "/media/20646/eth_logo.png",
          "Url": "/coins/eth/overview"
        }
      }
    ];
    
    const coinNames = arr.map(x => x.CoinInfo.FullName);
    
    console.log(coinNames);

提交回复
热议问题