Created
April 19, 2020 20:35
-
-
Save djds23/060c53d6b37d690f070a609c5e261fb3 to your computer and use it in GitHub Desktop.
Chapter 2 For the WAC Study Group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let output = ""; | |
let character = "#"; | |
for (let count = 0; count < 7; count += 1) { | |
output += character; | |
console.log(output); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (let count = 1; count <= 100; count += 1) { | |
// conditional to check count is divisible 3 | |
if (count % 3 == 0 && count % 5 == 0) { | |
console.log("FIZZBUZZ"); | |
} else if (count % 3 == 0) { | |
console.log("FIZZ"); | |
} else if (count % 5 == 0) { | |
console.log("BUZZ"); | |
} else { | |
console.log(count); | |
} | |
// conditional to check count is divisible 5 | |
// else log the number | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Write a program that creates a string that represents an 8×8 grid | |
let output = ""; | |
let gridSize = 7; | |
let blackSpace = "#"; | |
let whiteSpace = " "; | |
// outer loop go through each row | |
for (let row = 0; row <= gridSize; row += 1) { | |
let firstCharacter; | |
let secondCharacter; | |
if (row % 2 == 0) { | |
firstCharacter = whiteSpace; | |
secondCharacter = blackSpace; | |
} else { | |
firstCharacter = blackSpace; | |
secondCharacter = whiteSpace; | |
} | |
// inner loop go through each column in each row | |
for (let column = 0; column <= gridSize; column +=1) { | |
if (column % 2 == 0) { | |
output += firstCharacter; | |
} else { | |
output += secondCharacter; | |
} | |
console.log(`Updated Column:\n${output}`); | |
} | |
output += "\n" | |
console.log(`Starting New Row:\n${output}`); | |
} | |
console.log("Final output!") | |
console.log(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment