Literals

var arr = [ { "Name": "chevrolet chevelle malibu", "Cylinders": 8, "Displacement": 307, "Horsepower": 130, "Weight_in_lbs": 3504, "Origin": "USA" }, { "Name": "buick skylark 320", "Miles_per_Gallon": 15, "Cylinders": 8, "Displacement": 350, "Horsepower": 165, "Weight_in_lbs": 3693, "Acceleration": 11.5, "Year": "1970-01-01", }, { "Miles_per_Gallon": 18, "Cylinders": 8, "Displacement": 318, "Horsepower": 150, "Weight_in_lbs": 3436, "Year": "1970-01-01", "Origin": "USA" }, { "Name": "amc rebel sst", "Miles_per_Gallon": 16, "Cylinders": 8, "Displacement": 304, "Horsepower": 150, "Year": "1970-01-01", "Origin": "USA" }, ] names = Object .entries( arr.reduce( (prev, next) => { return { ...prev, ...next }; } )) .map(entry => entry[0]); str = ""; str += "" + names .map(name => ``) .join('') + ""; str += arr .map(obj => `${ names .map(name => ``) .join('') }`) .join(''); str += "
${name}
${obj[name] || "-"}
"; document.write(str)