Last active
December 6, 2020 03:58
-
-
Save ericdouglas/8781354 to your computer and use it in GitHub Desktop.
Resolução do Exercício 03 do Capítulo 03 - JavaScript Eloquente
This file contains hidden or 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
var | |
tamanho = 8, | |
tijolo1 = "#", | |
tijolo2 = " ", | |
parede1 = "", | |
parede2 = " ", | |
auxiliar = true, | |
contador = 1; | |
while ( contador < tamanho ) { | |
if ( auxiliar ) { | |
parede1 += tijolo1; | |
parede2 += tijolo1; | |
contador += 1; | |
auxiliar = !auxiliar; | |
} else { | |
parede1 += tijolo2; | |
parede2 += tijolo2; | |
contador += 1; | |
auxiliar = !auxiliar; | |
} | |
} | |
while ( contador > 1 ) { | |
if ( !auxiliar ) { | |
console.log( parede1 ); | |
contador -= 1; | |
auxiliar = ! auxiliar; | |
} | |
console.log( parede2 ); | |
contador -= 1; | |
auxiliar = ! auxiliar; | |
} |
var tamanho = 8
var xadrez;
for( y = 0; y < tamanho; y++){
xadrez = "";
for( x = 0; x < tamanho; x++){
if(y % 2){
xadrez += " ";
xadrez += "#"
}else{
xadrez += "#";
xadrez += " ";
}
}
console.log(xadrez);
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for
(var i = 1; i <= 8; i++) {if
(i % 3 == 0){console.log("#
# # #")}else
if
((i % 2 == 0) && (i % 3 == 0,33)){console.log
(" # # # #") }}