Created
January 30, 2012 19:40
-
-
Save adjohu/1706222 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
<script> | |
var size = 25; | |
var spaces = 6; | |
var row=0; | |
// Make spaces string | |
spaces = new Array(spaces).join(" "); | |
// loop through row | |
while(row < size){ | |
var column=0; | |
// loop through column | |
while(column < size){ | |
if( | |
row == column || // Coords 1,1 2,2 etc (first line) | |
(size - column) == row // 1, size -1 2,size-2 etc | |
){ | |
document.write("X"); | |
}else{ | |
document.write(spaces); | |
} | |
// Increment column counter | |
column++; | |
} | |
// new line after each row | |
document.write( "<br />"); | |
// Increment row counter | |
row++; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment