Looping a Triangle:
let num_rows = 7
for (let row = 0; row < num_rows; row++) {
let toPrint = “#”
for(let column = 0; column<row; column++){
toPrint += “#”;
}
console.log(toPrint);
}
FizzBuzz:
for (var i = 1; i <= 100; i++) {
var output = “”;
if( i % 3 == 0) { output += “Fizz”; }
if( i % 5 == 0) { output += “Buzz”; }
if( output == “”) { output = i; }
console.log(output);
}
Chessboard:
let size = 8;
let toPrint = “”;
for (let row = 0; row < size; row++) {
for (let col = 0; col < size; col++) {
if ((row + col) % 2 == 0) {
toPrint += " ";
} else {
toPrint += “#”;
}
}
toPrint += “\n”;
}
console.log(toPrint);