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
<!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
import { Component } from "react"; | |
import Order from "./ChildComponent"; | |
import { TEST_STUDENTS } from "./shared/student-test-data"; | |
// function App(props) { | |
// return ( | |
// <div className="App"> | |
// <p className="my-class"></p> | |
// </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
// We ran out of time, but here's one way we could have refactored our code if we wanted it to be more customizable | |
// Line 17 uses a ternary operator, which is somethign we'll be using more and more going forward! | |
function likes(names) { | |
let verb = "like"; | |
if(names.length < 2) verb += "s"; | |
nameList = names[0]; | |
if(names.length === 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
const TODO_ENDPOINT = 'https://crudcrud.com/api/f46d311529d04ee293015b2023d2b949/todos'; | |
// Little helper function for convenience | |
const getFetchOptions = (method, data) => ({ | |
method: method, | |
headers: { "Content-Type": "application/json" }, | |
body: JSON.stringify(data) | |
}) |
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 countDevelopers(list) { | |
return list.filter( d => d.continent === "Europe" && d.language === "JavaScript" ).length; | |
} | |
// OLD VERSION 3 | |
function countDevelopersOld3(list) { | |
return list.filter( developer => developer.continent === "Europe" && developer.language === "JavaScript" ).length; | |
} | |
// OLD VERSION 2 |
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
// https://www.codewars.com/kata/563b1f55a5f2079dc100008a | |
function getLargerNumbers(a, b) { | |
return a.map( (aItem, index) => Math.max(aItem, b[index]) ); | |
// const newArray = a.map( (aItem, index) => { | |
// const bigger = Math.max(aItem, b[index]) | |
// return bigger; | |
// }) |
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
// https://www.codewars.com/kata/56b1f01c247c01db92000076/train/javascript | |
function doubleChar(str) { | |
let result = ""; | |
// loop over the string | |
for(let i = 0; i < str.length; i++) { | |
// get the character that we're at for this looping | |
const character = str[i]; | |
// add the doubled character to the result | |
result += character + character; |
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; | |
} | |
// Returns true or false depending on if it's in the list or not | |
isAcceptedAnswer(potentialAnswer) { | |
return this.acceptedAnswers.includes(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
// https://www.codewars.com/kata/515bb423de843ea99400000a/train/javascript | |
// The constructor takes in an array of items and a integer indicating how many | |
// items fit within a single page | |
class PaginationHelper { | |
constructor(collection, itemsPerPage) { | |
this.collection = collection; | |
this.itemsPerPage = itemsPerPage; | |
} |