Functional Javascript: Having trouble iterating through an object that has nested objects and arrays -


i'm having difficulty trying access data in table structured below. want clean , efficient way of accessing nested data through functional javascript approach. if can show how can done functionally using ramda or plain es6 it'd appreciated! please see example table structure below.


let tables = {   table1: {     headings: [ 'hey', 'there' ],     rows: [ 'row 1 here', 'row 2 here' ],   },   table2: {     headings: [ 'sup', 'yall' ],     rows: [ 'row1 3 here', 'row 4 here' ],   },   table3: {     headings: [ 'what', 'up' ],     rows: [ 'row 5 here', 'row 6 here' ],   }, } 

edit

i using react , end goal me construct each table within table component, hoping able below within component const headings = [ 'hey', 'there' ] const rows = [ 'row 1 here', 'row 2 here' ]

if you're asking how enumerate data structure, work:

let tables = {    table1: {      headings: ['hey', 'there'],      rows: ['row 1 here', 'row 2 here'],    },    table2: {      headings: ['sup', 'yall'],      rows: ['row1 3 here', 'row 4 here'],    },    table3: {      headings: ['what', 'up'],      rows: ['row 5 here', 'row 6 here'],    },  };      object.keys(tables).foreach((tableid) => {      tables[tableid].headings.foreach((heading) => {      // heading    });      tables[tableid].rows.foreach((row) => {      // row    });  });


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -