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
import React, { Component } from 'react' | |
import PostList from './components/PostList' | |
export default class App extends Component { | |
render() { | |
return ( | |
<div> | |
This text is in App.js | |
<PostList/> |
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
// Call the render function when the page loads in using the jquery ready function | |
$(function() { | |
renderDishList(); | |
}) | |
function createDish() { | |
// grab the stuff from the form and use that to create a new object | |
const dish = { | |
title: $("#title-input").val(), |
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
/** | |
* A prompt that asks a question and only allows certain answers, case insensitive | |
*/ | |
class QuestionPrompt { | |
constructor(question, acceptedAnswers) { | |
this.question = question; | |
this.acceptedAnswers = acceptedAnswers; | |
} | |
getAcceptedAnswer(potentialAnswer) { |
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
/** | |
* A prompt that asks a question and only allows certain answers, case insensitive | |
*/ | |
class AcceptedAnswersPrompt { | |
constructor(question, acceptedAnswers) { | |
this.question = question; | |
this.acceptedAnswers = acceptedAnswers; | |
} |
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
export default function Note() { // creating a function | |
const match = useRouteMatch(); // calling a function and saving it in a variable | |
const { noteId } = useParams(); | |
const note = useSelector(state => state.notes.find(n => n.id === noteId)); // calling a function with a parameter | |
return ( // returning something from a function | |
<div className="container mt-3"> | |
{ (!note) ? <Redirect to="/notfound"/> : | |
<Switch> | |
<Route path={`${match.path}/edit`}> |
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
let animals = [ | |
{ | |
type: "cat", | |
name: "Floof", | |
votes: 0 | |
}, | |
{ | |
type: "dog", | |
name: "Spot", | |
votes: 0 |
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 getAnswer(question) { | |
const answer = prompt(question); | |
return answer; | |
} | |
function start() { | |
let name = getAnswer("What is your name?") | |
alert("Hello " + name) | |
name = getAnswer("What is your name?") |
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
body { | |
background-color: #fafafa; | |
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; | |
margin: 0; | |
padding: 0; | |
} | |
p { | |
font-family: Arial, Helvetica, sans-serif; |
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
let number = Math.ceil(Math.random() * 10) | |
alert("The secret number is " + number) // just for testing | |
let gameOn = true | |
while (gameOn) { | |
let guess = prompt("Guess a number between 0 and 10") | |
if (guess === null || guess === "null" || guess === ""){ | |
alert("Game cancelled. Refresh to start again.") | |
gameOn = false | |
} else if (parseInt(guess) === number) { |
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
let numCats = prompt("How many cats do you have?"); | |
numCats = parseInt(numCats); // convert the string (ex: "3") to the number (ex: 3) | |
if(numCats < 1) { | |
console.log("You need more cats") | |
} | |
else if(numCats > 10) { | |
console.log("That is tooo many cats") | |
} | |
else { |