Created
January 30, 2012 19:25
-
-
Save adjohu/1706133 to your computer and use it in GitHub Desktop.
This file contains 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
<div id="a"></div> | |
<script> | |
var size = 20; | |
// 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(" "); | |
} | |
} | |
// 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