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, {useState} from "react"; | |
import {Link, NavLink, Route, Switch, useParams, useRouteMatch} from "react-router-dom"; | |
import UserPosts from "./UserPosts"; | |
import UserProfile from "./UserProfile"; | |
export const User = ({ users = [] }) => { | |
const [showPosts, setShowPosts] = useState(false)//to show profile and post | |
const {url} = useRouteMatch() |
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 "./styles.css"; | |
/* | |
Add event listeners to the .expand_button buttons | |
*/ | |
const expandButtonClickHandler = (event) => { | |
const article = event.target.parentNode.parentNode.parentNode; | |
const article_body = article.querySelector('.article_body'); |
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 ratings = require("../data/ratings-data"); | |
function ratingExists(req, res, next) { | |
const ratingId = Number(req.params.ratingId); | |
const foundRating = ratings.find((rating) => rating.id === ratingId); | |
if (foundRating === undefined) { | |
return next({ |
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
//////////////////////////// | |
// DO NOT EDIT THIS ARRAY // | |
//////////////////////////// | |
/* | |
The contacts array contain the list of contacts for the contact book. | |
*/ | |
window.contacts = [ | |
{ | |
id: 1, | |
name: "Leanne Graham", |
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 service = require("./restaurants.service.js"); | |
const asyncErrorBoundary = require("../errors/asyncErrorBoundary"); | |
async function averageRating(req, res, next) { | |
const ratingReturned = await service.averageRating(); | |
let {avg: rating} = ratingReturned; | |
rating = parseFloat(rating) | |
res.json({ data: {average_rating: rating} }); | |
} |
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 findAuthorById(authors, id) { | |
let found = authors.find((author) => author.id === id) | |
return found | |
} | |
function findBookById(books, id) { | |
let found = books.find((book) => book.id === id) | |
return found | |
} |
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 LinkedList = require("./linkedList"); | |
class Queue { | |
constructor() { | |
this.linkedList = new LinkedList(); | |
} | |
enqueue(value) { | |
this.linkedList.insert(value); | |
} |
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
App.js---------------------------- | |
import React, { Fragment } from "react"; | |
import { Link, NavLink, Route, Switch, useParams, useRouteMatch} from 'react-router-dom' | |
import Header from "./common/Header"; | |
import CardList from "./home/CardList"; | |
import User from "./user/User"; | |
import NotFound from "./common/NotFound" |
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 printNames (names) { | |
names.forEach((name) => { | |
console.log(name); | |
}); | |
} | |
function logTreeType (trees){ | |
trees.forEach((tree) => { | |
console.log (tree.type); |
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 partitionStudentsByScore(students, score) { | |
const result = [] | |
const target = [] | |
const excess = [] | |
students.forEach(student => { | |
student.score <= score ? target.push(student) : excess.push(student) | |
}) | |
result.push(target, excess) | |
return result; | |
} |
OlderNewer