Created
January 26, 2017 22:31
-
-
Save defvol/fc2d56f250b8cadb2988bf03afb2985c to your computer and use it in GitHub Desktop.
Traverse object's properties to build an HTML table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function toTable (obj) { | |
var td = function (s) { return '<td>' + s + '</td> ' }; | |
var tr = function (s) { return '<tr>' + s + '</tr> ' }; | |
var table = '' | |
for (var k in obj) table += tr(td(k) + td(obj[k])); | |
return '<table>' + table + '</table>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment