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
function getMostCommonGenres(books) { | |
let countObj = {}; | |
books.forEach(aBook => { | |
if (countObj[aBook.genre] != null) { | |
countObj[aBook.genre]++; | |
} else { | |
countObj[aBook.genre] = 1; | |
} | |
}); | |
let countArray = []; |
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
// Reference: http://lea.verou.me/2011/10/easily-keep-gh-pages-in-sync-with-master/ | |
$ git add . | |
$ git status // to see what changes are going to be commited | |
$ git commit -m 'Some descriptive commit message' | |
$ git push origin master | |
$ git checkout gh-pages // go to the gh-pages branch | |
$ git rebase master // bring gh-pages up to date with master | |
$ git push origin gh-pages // commit the changes |
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
const printNames = names=> { | |
names.forEach((names)=> | |
console.log(names)); | |
} | |
const logTreeType=trees=>{ | |
trees.forEach((tree)=> | |
console.log(tree.type)); | |
} | |
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
/* | |
The following functions have various syntax errors in them. Fix the bugs to get the tests to pass! | |
When any of the following function's parameters reference `products`, they are referencing an array full of objects with the following shape: | |
{ | |
name: "Slip Dress", | |
priceInCents: 8800, | |
availableSizes: [ 0, 2, 4, 6, 10, 12, 16 ], | |
quantity: 0 | |
} |
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
const findStudentScoreByName = require("../src/solution"); | |
const expect = require("chai").expect; | |
describe("Checking equality", () => { | |
it("should return a student score if the name matches", () => { | |
const students = [ | |
{ name: "Leo Yeon-Joo", score: 8.9 }, | |
{ name: "Morgan Sutton", score: 7.4 }, |
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
// App | |
import React, { useState } from "react"; | |
import Content from "./Content"; | |
import Header from "./Header"; | |
function App () { | |
const [loggedIn, setLoggedIn] = useState(false); | |
const toggleLoggedIn = () => setLoggedIn(!loggedIn); | |
const [fontSize, setFontSize] = useState(12); | |
const increaseSize = () => setFontSize(fontSize+2); |
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
function listAllItems(products) { | |
if(products.length === 0){ | |
return `There are no items for sale.`; | |
} | |
if(products.length === 1){ | |
return `There is 1 item for sale: ${products[0].name}.`; | |
} | |
if(products.length === 2){ | |
return `There are ${products.length} items for sale: ${products[0].name} and ${products[1].name}.`; |
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
// should return all of the books taken out by an account with the author embedded | |
function getBooksPossessedByAccount(account, books, authors) { | |
let books_taken = []; | |
books.forEach(book=>{ | |
if (book.borrows.find(item=>item.id === account.id && !item.returned)) { | |
books_taken.push(book); | |
} | |
}) | |
console.log(books_taken); | |
books_taken.forEach(book=>{ |
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
function addProductToCart({ name, priceInCents }, cart = {}) { | |
const selected = cart[name]; | |
if (selected) { | |
selected.quantity++; | |
} else { | |
cart[name] = { priceInCents, quantity: 1 }; | |
} | |
return cart; | |
} |
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
function printNames (names) { | |
names.forEach(name => console.log(name)); | |
} | |
function logTreeType (trees) { | |
trees.forEach(type => console.log(type.type)); | |
} | |
function totalPoints(points) { | |
// your solution here |