JavaScript table not showing [closed]

I'm practicing this question where I'm supposed to make a table programatically and although I'm not getting any errors the table is not showing.

var ROWS = 13;
var COLS = 2;

var out = document.getElementsByClassName("funky")[0];
var table = document.createElement("table");
table.border = 1;
for (var i=0; i < ROWS; i += 1) {
var row = document.createElement("tr");
for (var j=0; j < COLS; j += 1) {
var col = document.createElement("td");
col.innerHTML = String.fromCharCode(i + j);
if (i % 3 == 0) {
col.style.color = "red";
} else if (i % 3 == 1) {
col.style.color = "green";
} else if ((j) % 3 == 2) {
col.style.color = "blue";
}
}
table.appendChild(row);
}
table.appendChild(col);
}

closed as off-topic by Ethan Bierlein, BCdotWEB, mdfst13, forsvarir, GraipherDec 1 '16 at 16:06

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Questions containing broken code or asking for advice about code not yet written are off-topic, as the code is not ready for review. After the question has been edited to contain working code, we will consider reopening it." – Ethan Bierlein, BCdotWEB, mdfst13, forsvarir, Graipher
If this question can be reworded to fit the rules in the help center, please edit the question.

It should be something like this.

<script>
var ROWS = 13;
var COLS = 2;

var out = document.getElementsByClassName("funky")[0];
var table = document.createElement("table");
table.border = 1;
for (var i=0; i < ROWS; i += 1) {
var row = document.createElement("tr");
for (var j=0; j < COLS; j += 1) {
var col = document.createElement("td");
col.innerHTML = i;
if (i % 3 == 0) {
col.style.color = "red";
} else if (i % 3 == 1) {
col.style.color = "green";
} else if ((j) % 3 == 2) {
col.style.color = "blue";
}
row.appendChild(col);
}
table.appendChild(row);
}
//table.appendChild(col);
document.body.appendChild(table);
}
</script>

• So my only mistake was "document.body.appendChild(table);" ? – Inconnu Dec 1 '16 at 14:23
• Please don't answer off-topic questions; this makes it hard for later clean-up. – BCdotWEB Dec 1 '16 at 14:25
• Okay sorry, I'll delete this then? – Inconnu Dec 1 '16 at 14:25
• yes you may delete, it's more like a question in stack overflow. you have to add col to row. – Barani Dec 1 '16 at 14:31