Question: Javascript expertise. Pls no html in the solution. Thx The variable tableData below represents data as it might appear in a table or spreadsheet. The
Javascript expertise. Pls no html in the solution. Thx
The variable tableData below represents data as it might appear in a table or spreadsheet. The first array contains column names and the rest of the arrays are rows of data. Write a function convertTable that converts the data in a nested array like tableData to an array of objects that matches the output below. Your function should work for any array formatted like tableData, meaning it should always use the first array given as the keys and the rest of the arrays as values.
For example:
const tableData = [ ["first_name", "last_name", "city", "state"], ["Elisabeth", "Gardenar", "Toledo", "OH"], ["Jamaal", "Du", "Sylvania", "OH"], ["Kathlyn", "Lavoie", "Maumee", "OH"] ] convertTable(tableData) // The return is below [ { first_name : "Elisabeth", last_name : "Gardenar", city: "Toledo", state : "OH" }, { first_name : "Jamaal", last_name : "Du", city: "Sylvania", state : "OH" }, { first_name : "Kathlyn", last_name : "Lavoie", city: "Maumee", state : "OH" } ]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
