December 2023
Intermediate to advanced
242 pages
5h 28m
English
| Recipe 11 | Generating HTML Tables from an Array of Objects |
Suppose your task is to generate reports of data that are stored in an array of objects like the following:
| | const data = [ |
| | {quarter: "Q1 FY22", revenue: 45962, netIncome: 20820, eps: 2.71}, |
| | {quarter: "Q2 FY22", revenue: 44845, netIncome: 20610, eps: 2.71}, |
| | {quarter: "Q3 FY22", revenue: 46151, netIncome: 16027, eps: 2.03}, |
| | {quarter: "Q4 FY22", revenue: 46822, netIncome: 16244, eps: 2.11}, |
| | {quarter: "Q1 FY23", revenue: 45215, netIncome: 20256, eps: 2.64} |
| | ]; |
In the previous recipe, you created a table using an array of arrays. But, for this recipe, the data is stored in an array of objects. This means that you need to use a slightly different approach to generate a table. ...
Read now
Unlock full access