<!DOCTYPE html>
<script type = "text/javascript">
window.onload = function(){
document.body.appendChild(
function(rows, cols){
var table = document.createElement("TABLE"), tr, td;
for(var r = 0; r < rows; r ++){
table.appendChild(
(function(){
tr = document.createElement("TR");
for(var c = 0; c < cols; c ++){
tr.appendChild(
(function(){
td = document.createElement("TD");
td.innerHTML = "row: " + r + ", cell: " + c;
td.style.border = "1px solid red";
return td;
}())
)
}
return tr;
}())
)
}
return table;
}(10, 7)
)
}
</script>