-
Triangle.
//I came into the exercises absolutely overwhelmed by all new information. I had to go through MANY answers of other classmates, first typing their code out manually to hammer the functionalities into my working memory. After many hours I finally reached a point where I was able not only to somewhat read the code but even when I tried running code that wasn’t functional managed to see what someone meant to do and debug it. Proud over my quarantine progress and ready to post the solutions as I’ve found them most understandable//
for(var row = 0; row <7; row++)
{
var hash = “#”;
for (var column = 0; column < row; column++)
{
hash = hash + “#”;
}
console.log(hash);
}
-
FizzBuzz
Still have a hard time understanding the math, if x, which is 1 is divided by 3 how does it ever turn to zero? 3/1 = 1, if anyone could explain this to me I’d be grateful.
Also I have still not understand how {} really work. They’re basically just in the right place because of endless trial and error.
for(var x = 1; x < 101; x++)
{
if (x % 3 == 0 && x % 5 == 0){
console.log (“Fuxsbox”);
} else if(x % 5 == 0) {
console.log(“Box”);
} else if(x % 3 == 0) {
console.log(“Fuxs”);
} else
console.log(x);
}
- 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);