• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Array getJSON by Index

Resolved: Array getJSON by Index

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I want to showing data like this:
I’ve trying some method, but still get confused and showing not what I want. By the code below:
It’s only showing like this :
I have JSON format like this:

Answer:

Given the format of your data where the name/count are in separate arrays, you can use a basic for loop to get the index for each disaster, to get the corresponding name/count based on that index
This assumes there’s the same number of disaster names as counts and that the associated values are in the same order – eg count[0] is for forest fires.


As you can change the format, you could make it more object-like, eg an array of:
then the js will be closer to your initial attempt as you don’t need to loop the index and can use a .forEach() or .map()


If you have better answer, please add a comment about this, thank you!

jquery json
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Visual Studio 2022 crashes when using breakpoints

24/03/2023

Resolved: How to get Union type from an array of objects in Flow?

24/03/2023

Resolved: Modify entity using Action in C#

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.