I really struggled with this exercise. I re-read several parts of the book and looked at various sites after attempting these many times. I am still not confident in these exercises so i am going to go back over the material before proceeding.
Triangle
var numRows = 7;
for(let row = 0; row < numRows; row++){
var printS = ("#");
for(let column = 0; column < row; column++){
printS += "#";
}
console.log(printS);
}
FizzBuzz
for (number = 1; number<100; number++){
if (number % 15 == 0) console.log(“fizzbuzz”);
else if (number % 3 == 0 ) console.log(“Fizz”);
else if (number % 5 == 0) console.log(“Buzz”);
else console.log(number);
}
Chess
let size = prompt("Enter size of the Chessboard: ");
let chess = “”;
for (row = 0; row < size; row++){
for (column = 0; column < size; column++){
if (column % 2 == 0 && row % 2 == 0){
chess += " ";
}
else if (column % 2 == 0 && row % 2 == 1){
chess += "#";
}
else if (column % 2 == 1 && row % 2 == 1){
chess += " ";
}
else {
chess += "#";
}
}
chess += "\n";
}
console.log(chess);