Skip to content

Instantly share code, notes, and snippets.

@adjohu
Created January 30, 2012 19:28
Show Gist options
  • Save adjohu/1706150 to your computer and use it in GitHub Desktop.
Save adjohu/1706150 to your computer and use it in GitHub Desktop.
<div id="a"></div>
<script>
var size = 5;
// loop through row
for(var row=0; row <= size; row++){
// loop through column
for(var column=0; column <= size; column++){
if(
row == column || // Coords 1,1 2,2 etc (first line)
(size - column) == row // 1, size -1 2,size-2 etc
){
console.log('x');
document.write("X");
}else{
document.write("&nbsp;");
}
}
// new line after each row
document.write( "<br />");
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment