Finally! Done! I had to review, review, AND review…then, google
Looping a Triangle:
Originally, for the var content = ‘#’ I used the # sign followed by:
for (var i = 0; i < 7; i++) {
content = content + ‘#’;
console.log(content);
}
The only problem is the my triangle started with two ##, then I realized, I needed to omit the #, so here’ s my final answer:
var content = ‘’;
for (var i = 0; i < 7; i++) {
content = content + ‘#’;
console.log(content);
}
FIZZ BUZZ - I think I have some of my hair left on this one. It took me forever to figure, read and re-read, and Yes, Ivan, google search other examples:
for (i=1; i<=100; i++) {
if ( !(i%5) && !(i%3) ) {
console.log(‘FizzBuzz’);
} else if ( !(i%5) && (i%3)) {
console.log(‘Buzz’);
} else if ( !(i%3) ) {
console.log(‘Fizz’);
} else {
console.log(i);
}
}
##Chessboard:
var size = 8;
var block = ‘#’;
var space = ’ ';
for (var i = 1; i <= size; i++) {
var line = ‘’;
for (var y = 1; y <= size; y++){
if (i%2) {
if (y%2) {
line = line + space;
} else {
line = line + block;
}
} else {
if (y%2) {
line = line + block;
} else {
line = line + space;
}
}
}
console.log(line);
}