document.write(“This is the triangle example where we will take the hashmark(#), to create a triangle by increasing the number of #'s for each count.” + “
”)
let result = “”;
for(let counter = 0; counter < 9; counter = counter + 1)
{result = result + “#”; document.write(result + “
”)}
document.write(“For this next example we will take numbers between 1 to 100 and we will print each number except when the number is divisible by 3, we will print Fizzle, and when divisible by 5, we print Bizzle, and when it can be divided by both 3 & 5 we print FizzleBizzle, other wise we just print the number.”+ “
”)
let number =0;
for(let counter = 0; counter < 100; counter = counter + 1)
{number = number + 1;
if(number % 3 == 0 && number % 5 == 0)
{document.write(“FizzleBizzle” + “
”)}
else if(number % 3 == 0){document.write(“Fizzle” + “
”)}
else if(number % 5 == 0){document.write(“Bizzle” + “
”)}
else{document.write(number + “
”)}}
document.write(“For this last example we will print a chess board where we will use the blank space and hash-mark to represent the white and black squares” + “
”)
let string = “# # # # # # # #”;
let string2 = " # # # # # # # #";
for(counter = 1; counter < 9; counter = counter + 1)
{if(counter % 2 == 0){document.write(string+"
")}
else {document.write(string2 + “
”)}}
This last script works inside the console of the browser but will not recognize the empty space in the string2. I could not do anything or find anything that would allow it to print the empty space before printing the hash-mark in string 2.
The first two worked with no problem. But it took me about a hour or two to get the second two work but it has to do with my syntax. Once I got the syntax right it was no problem. Adding the Fizzle and Bizzle combination was simple once I got the Fizzle and Bizzle to work in less than 5 min,
However I also tried to do a .css stylesheet for the output and I had some success but had some major problems. I had to run the script after the body and the end for the script to work. It would not run within the body for some reason. I was trying to make a Header , Navigation, Contents, I wanted to use the Nav bar to activate the script for either program and then run it in the contents section of the page.
All in All it was a lot of fun but a challenge. I think I got in over my head truing to add the .css and Nav to run the program.