Created
January 14, 2018 12:58
-
-
Save mayashavin/bc07f5d67a24b6101354bfc55e324a32 to your computer and use it in GitHub Desktop.
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
//Input: Array of Arrays of Cells | |
var grid = [['name', 'height', 'country'], | |
['Kilimanjaro',5895, 'Tanzania'], | |
['Everest',8848,'Nepal'], | |
['Mount Fuji',3776,'Japan'], | |
['Mont Blanc',4808,'Italy/France'], | |
['Vaalserberg',323,'Netherlands'], | |
['Denali', 6168,'United States'], | |
['Popocatepetl', 5465,'Mexico']]; | |
function getColWidths(rows){ | |
var colWidths = []; | |
for (var i = 0; i < rows[0].length; i++){ | |
colWidths.push(rows.reduce(function(maxWidth, row){ | |
return Math.max(maxWidth, row[i].length); | |
}, 0); | |
} | |
} | |
function getRowHeight(rows){ | |
} | |
function Cell(content){ | |
var content = content; | |
return{ | |
minWidth: function(){ return content.length;}, | |
minHeight: function(){ return 1;}, | |
draw: function(width, height){ | |
var cell = content; | |
for (var i = content.length; i < width; i++){ | |
cell += " "; | |
} | |
return cell; | |
} | |
} | |
} | |
function drawTable(grid){ | |
var colWidths = getColWidths(grid); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment