Skip to content

Instantly share code, notes, and snippets.

@neruthes
Created April 10, 2014 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neruthes/10402510 to your computer and use it in GitHub Desktop.
Save neruthes/10402510 to your computer and use it in GitHub Desktop.
// Claim a function
function arrayToTable(arr) {
var table = document.createElement("table")
for (i = 0; i < arr.length; i++) {
var tr = document.createElement("tr")
for (j = 0; j < arr[i].length; j++) {
var td = document.createElement("td")
td.appendChild(document.createTextNode(arr[i][j]))
tr.appendChild(td)
}
table.appendChild(tr)
}
return table
}
// Call the function
var arr0 = [133, 435, 345, 345, 576, 6543, 462]
var arr1 = [2, 435, 345, 345, 576, 6543, 4674, 1234, 63456, 123, 685, 422]
var arr2 = [3, 435, 345, 345, 576, 6543, 63456, 123, 685, 422]
var arr3 = [4, 435, 345, 345, 576, 6543, 4674, 1234, 63456, 123, 685, 422]
var arr4 = [5, 435, 6543, 4674, 1234, 63456, 123, 685, 422]
var arr5 = [6, 435, 345, 6543, 4674, 1234, 682]
var arr = [arr0, arr1, arr2, arr3, arr4, arr5]
document.body.appendChild(arrayToTable(arr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment