This file contains hidden or 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
class Connect4 { | |
constructor() { | |
// 7 columns and 6 rows | |
this.column = [0, 0, 0, 0, 0, 0]; | |
this.currentPlayer = 1; // 2 | |
} | |
play(col) { |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>GOES IN THE TOP TAB</title> | |
</head> | |
<body> | |
<!-- <div>fdsfds</div> |
This file contains hidden or 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
class Die { | |
constructor(letters) { | |
this.topLetter = letters[0]; | |
this.allLetters = letters; | |
} | |
roll() { | |
const randomIndex = Math.floor(Math.random() * this.allLetters.length) | |
this.topLetter = this.allLetters[randomIndex]; | |
} |
This file contains hidden or 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
class Die { | |
// letters = array of strings of letters on this die | |
constructor(letters) { | |
this.allLetters = letters; | |
this.currentLetter = letters[0] | |
} | |
reroll() { | |
const randomIndex = Math.floor(Math.random() * this.allLetters.length) | |
this.currentLetter = this.allLetters[randomIndex]; |
This file contains hidden or 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
class User { | |
constructor(username) { // firstName = "Natalie"; lastName = "Childs" | |
this.username = username; | |
this.isAdmin = false; | |
} | |
greet() { | |
alert("Hello " + this.username + "!") | |
} |
This file contains hidden or 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
class AcceptedAnswerPrompt { | |
constructor(acceptableAnswers) { // acceptableAnswers = ["cat", "dog", "unicorn"] | |
this.acceptableAnswers = acceptableAnswers; | |
} | |
promptForAcceptable(question) { | |
let answer = prompt(question); // calling normal Javascript prompt | |
// let foundAnswer = undefined; |
This file contains hidden or 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
/***** Converting Between Arrow and Normal Functions *****/ | |
// Normal Function | |
function isJose(user) { | |
return user.username === "jose" | |
} | |
// Arrow Function | |
const isJose = (user) => { | |
return user.username === "jose" |
This file contains hidden or 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
/***** Converting a Normal Function to an Arrow Function ******/ | |
function isJose(user) { | |
return user.username === "jose" | |
} | |
// converted to arrow function syntax | |
const isJose = (user) => { | |
return user.username === "jose" | |
} |
This file contains hidden or 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
/******** Arrays ********/ | |
let names = [ | |
"Abigail", | |
"Marco", | |
"Simone", | |
"Derek" | |
] | |
console.log(names); |
This file contains hidden or 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
/******** Arrays ********/ | |
let names = [ | |
"Abigail", | |
"Marco", | |
"Simone", | |
"Derek" | |
] | |
let allTheNames = "" |