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
const messages = [ | |
{ | |
id: 0, | |
from: "Abigail", | |
text: "Are you here yet?", | |
unread: true | |
}, | |
{ | |
id: 1, | |
from: "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
function App() { | |
const [channels, setchannels] = useState(INITIAL_CHANNELS) | |
const handleUpdateChannel = (updatedChannelData) => { | |
// set the state to the new updated data | |
} | |
return ( | |
<div> | |
<Sidebar channelList={ channels }/> |
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
addLike() { | |
//this.state.transactionList = fdjskflds // DO NOT CHANGE STATE DIRECTLY | |
// let something = this.state.transactionList.push({ fdjskfldsfjklds }) // DO NOT CHANGE STATE DIRECTLY | |
// this.setState({ transactionList: something }) | |
this.setState(state => ({ numLikes: state.numLikes + 1 }) ) | |
// adding | |
this.setState( state => ({ transactionList: [ ...state.transactionList, "fdsfdsfsd"] }) ) | |
this.setState( state => ({ transactionList: state.transactionList.concat(["fdsfdsfsd"]) }) ) |
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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<script src="week2.js"></script> |
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
function cookInOven(food, temperature) { // food = "chicken", temperature = 425 | |
return food + " cooked at " + temperature | |
} | |
function cookDinner(ingredients) { | |
var cookedFoodArray = []; | |
for(let i = 0; i < ingredients.length; i++) { | |
var cookedFood = cookInOven(ingredients[i], 400) | |
cookedFoodArray.push(cookedFood) | |
} |
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
// Working with one email | |
const emailFromNatalie = { | |
author: "Natalie", | |
to: "Calvin", | |
message: "Heyyyy", | |
read: false | |
} | |
alert(emailFromNatalie.message) |
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
// Prompt for a number of cats and parse it into a number | |
var numCats = prompt("How many cats do you have?") | |
numCats = parseInt(numCats) | |
// Loop as long as they don't give us a real number | |
while( !(numCats >= 0) ) { | |
numCats = prompt("No really, how many cats?"); | |
numCats = parseInt(numCats) | |
} |
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(acceptedAnswers) { | |
this.acceptedAnswers = acceptedAnswers; | |
} | |
checkIfAccepted(answer) { | |
// return true if it is in the list of accepted answer | |
for(const acceptedAnswer of this.acceptedAnswers) { | |
if(acceptedAnswer === answer) { | |
return true; |
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
// Cooks in pressure cooker | |
function cookInPressureCooker(howLong, food) { // var howLong = 20; var food = "chicken" | |
return food + " cooked for " + 20 + " minutes"; | |
} | |
function makeDinner() { | |
var chicken = "chicken"; | |
var soup = "soup"; | |
chicken = cookInPressureCooker(20, "chicken"); |
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(acceptedAnswers) { | |
this.acceptedAnswers = acceptedAnswers; | |
} | |
checkIfAccepted(answer) { | |
// return true if it is in the list of accepted answer | |
for(const acceptedAnswer of this.acceptedAnswers) { | |
if(acceptedAnswer === answer) { |