Skip to content

Instantly share code, notes, and snippets.

View jsmney's full-sized avatar
🐱

Jasmine Wang jsmney

🐱
View GitHub Profile
import React, {useState, useEffect} from 'react'
const BirdSanctuary = props => {
const [birds, setBirds] = useState([])
useEffect(()=>{
setBirds(props.getBirds())
},[])
const feedBird = birdId => {
import React from 'react'
const SingleBird = props => {
return (
<div className="singleBird">
<h3>{props.bird.name}</h3>
<p>{props.bird.fed ? 'I have been fed!' : 'I need some food'}</p>
<button onClick={() => props.feedBird(props.bird.id)}>Feed</button>
</div>
)
import React, {useState, useEffect} from 'react'
const BirdSanctuary = props => {
// for example's sake, here is a default array of birds
const [birds, setBirds] = useState([
{id: 3, name: 'Polly', fed: false},
{id: 4, name: 'Tina', fed: true},
{id: 5, name: 'Marlow', fed: false}
])
Method Relationship Parameter Returns Side effects / notes
cat.addOwner() M:M owner {}, or ownerId created join table row
cat.addOwners() M:M array of owner {} or ownerId, can be a combination array of created join table rows
cat.countOwners() M:M none int
cat.createOwner() 1:1, 1:M, M:M new owner {} (what you could also pass into Owner.create() ) created owner object cat instance will have updated ownerId
cat.getOwner() 1:1, 1:M none owner object (if exists), or null
cat.getOwners() M:M none array of owner object(s)
cat.hasOwner() M:M owner {}, or ownerId boolean
cat.hasOwners() M:M array of owner {} or ownerId, can be a combination boolean returns true only if ALL owners own this cat
cat.removeOwner() M:M owner {}, or ownerId int number of owners removed

Introduction

Let's take a look at one of the best classic games!

Super Mario Bros NES

(https://www.youtube.com/watch?v=ia8bhFoqkVE "Super Mario Bros Gameplay") (Watch from 0:00 - 1:00)

If you already understand the basics of how Super Mario works, feel free to skip to the prompt!

Introduction

Let's take a look at one of the best classic games!

Super Mario Bros NES

(https://www.youtube.com/watch?v=ia8bhFoqkVE "Super Mario Bros Gameplay") (Watch from 0:00 - 1:00)

If you already understand the basics of how Super Mario works, feel free to skip to the prompt!

Prompt

Given a staircase with a given number of stairs, num, write a function that returns the number of different ways one can climb this set of stairs. A person is able to climb the stairs either one at a time, or skip a step, or a mix of both.

Examples

climbStairs(2); // should return 2: one step at a time (1 + 1), or skip a step (2).
climbStairs(0); // should return 1
climbStairs(1); // should return 1
climbStairs(5); // should return 8
climbStairs(100); // should return 573147844013817200640
@jsmney
jsmney / graphPathChecker.md
Created March 13, 2020 00:49
interviewer && interviewee gist

Graph Path Checker

Prompt

Write a function that determines if a path exists between two vertices of a directed graph.

Recall that a graph is a collection of connections, or 'edges', linking together nodes or verticies. In a directed graph, each edge is like an arrow or a one-way street-- an edge linking A to B indicates that A connects to B, but not that B connects to A.

The graph passed to the function will be represented as an object with a structure sometimes called an 'adjacency list' or 'adjacency map', in which each key represents a node in the graph, and each value will consist in an array of nodes which can be reached from the key. For example, the following object:

Prompt

Write a function that determines whether an input string has balanced brackets.

You are given an input string consisting of brackets—square [ ], round ( ), and curly { }. The input string can include other text. Write a function that returns either true if the brackets in the input string are balanced or false if they are not. Balanced means that any opening bracket of a particular type must also have a closing bracket of the same type.

An empty input string or a string without brackets can also be considered "balanced".

Examples

Act II:

Romeo lingers near the Capulet house to talk with Juliet when she appears in her window. The pair declare their love for one another and intend to marry the next day. With the help of Juliet's Nurse, the lovers arrange to marry when Juliet goes for confession at the cell of Friar Laurence. There, they are secretly married (talk about a short engagement).