Last active
August 18, 2018 10:51
-
-
Save hakimzulkufli/791d82ffa124ba91ffe4305064b81425 to your computer and use it in GitHub Desktop.
Print chess board. Alternate solution. Demo: https://codepen.io/anon/pen/qyezvX
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
<pre id="output"></pre> | |
<script> | |
var n = prompt("Enter value of N", 5), c = 1, str = ""; | |
for(i = 1; i<=n; i++) { | |
if(i % 2 === 0) c = 2; | |
else c = 1; | |
for(j = 1; j<=n; j++) { | |
if(c % 2 !== 0) str += "#"; | |
else str += " " | |
c += 1; | |
} | |
str += "<br />"; | |
} | |
document.getElementById("output").innerHTML = str; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment