JSFiddle - React, Tailwind, and code Playground

by grant

JavaScript

const data = {"UNITS":{"precipitation":"Inches"},"STATION":[{"STATUS":"ACTIVE","MNET_ID":"25","PERIOD_OF_RECORD":{"start":"20000120","end":"20180121"},"ELEVATION":"6340","NAME":"BOGUS BASIN","RESTRICTED":false,"STID":"BOGI1","ELEV_DEM":"6362","LONGITUDE":"-116.09685","STATE":"ID","OBSERVATIONS":{"precipitation":[{"count":23,"first_report":"20180115","interval":1,"report_type":"precip_accum","last_report":"20180115","total":0.0},{"count":24,"first_report":"20180116","interval":2,"report_type":"precip_accum","last_report":"20180116","total":0.2},{"count":24,"first_report":"20180117","interval":3,"report_type":"precip_accum","last_report":"20180117","total":0.0},{"count":24,"first_report":"20180118","interval":4,"report_type":"precip_accum","last_report":"20180118","total":0.0},{"count":24,"first_report":"20180119","interval":5,"report_type":"precip_accum","last_report":"20180119","total":0.8},{"count":24,"first_report":"20180120","interval":6,"report_type":"precip_accum","last_report":"20180120","total":0.0},{"count":13,"first_report":"20180121","interval":7,"report_type":"precip_accum","last_report":"20180121","total":0.0}]},"LATITUDE":"43.76377","TIMEZONE":"America\/Boise","ID":"1160"}],"SUMMARY":{"DATA_QUERY_TIME":1.6429424286,"RESPONSE_CODE":1,"RESPONSE_MESSAGE":"OK","METADATA_RESPONSE_TIME":"0.0920295715332 ms","NUMBER_OF_OBJECTS":1,"PRECIP_DATA_TIME":2.4950504303,"DATA_PARSE_TIME":0.8418560028}};


function toArray(obj) {
  const result = [];
  for (const prop in obj) {
    const value = obj[prop];
    if (typeof value === 'object') {
      result.push(toArray(value));
    } else {
      result.push(value);
    }
  }
  return result;
}

//console.log(toArray(data));
//console.log(data.OBSERVATIONS.total);
console.log(data.STATION[0].OBSERVATIONS.precipitation[4].total
);
//console.dir(data);
//for(let i = 0, l = data.items.length; i < l; i++) {
for(let i = 0, l =     data.STATION[0].OBSERVATIONS.precipitation[0].total.length; i < l; i++) {
// `i` will take on...