Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save manoelmaciel/bc0173c927ef648528ecfffa187e36c5 to your computer and use it in GitHub Desktop.
Save manoelmaciel/bc0173c927ef648528ecfffa187e36c5 to your computer and use it in GitHub Desktop.
// Tabuleiro de Xadrez
var stringTabuleiro = "";
var stringLinha = '';
var tamanho = 8;
for (linhas=0; linhas<tamanho; linhas++) {
if (linhas % 2 === 0) {
for (linha=0; linha<tamanho; linha++) {
if (linha%2 === 0) {
stringLinha += '#';
} else {
stringLinha += ' ';
}
}
stringLinha += '\n';
stringTabuleiro += stringLinha;
stringLinha = '';
} else {
for (linha=0; linha<tamanho; linha++) {
if (linha%2 === 0) {
stringLinha += ' ';
} else {
stringLinha += '#';
}
}
stringLinha += '\n';
stringTabuleiro += stringLinha;
stringLinha = '';
}
}
console.log(stringTabuleiro);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment