Skip to content

Instantly share code, notes, and snippets.

View laniehei's full-sized avatar
🐢
teaching turtles to tango

Lanie Hei laniehei

🐢
teaching turtles to tango
View GitHub Profile
@laniehei
laniehei / fork.sh
Created June 19, 2021 00:02
Set Fork Upstream
echo "What's your github clone URL?"
read URL
git remote add upstream $URL
git fetch upstream
# Solution 2.2 of foo.bar
def solution(h, q):
# We'll use a dictionary to hold the
# solutions so that we can store as
# q[x] = soln and later return back
# in order, regardless of how our
# algorithm iterates through the tree.
solutions = {}
@laniehei
laniehei / iterators.js
Created September 15, 2018 18:21 — forked from aegorenkov/iterators.js
HardParts Promises and Iterators
// Type JavaScript here and click "Run Code" or press Ctrl + s
console.log('Hello, world!');
// CHALLENGE 1
function sumFunc(arr) {
// YOUR CODE HERE
let accumulator = 0;
for (let i = 0; i < arr.length; i++) {
accumulator += arr[i];
// Destructuring === Arrays
var [a,b] = [1,2];
console.log(a,b);
//=> 1 2
// Omit certain values
var [a, , b] = [1, 2, 3];
console.log(a, b);
// 1 3
{"name": "Rusty", "room":"kitchen", "weapon":"candlestick"}
const obj = {name, weapon}
// Create an object using bracket and dot notation that represents the characters and related data you may find in a game of Clue.
var game = {};
game.murderer = "??";
game['weapons'] = [
{type: 'lasers', location: 'lab'},
{type: 'angry cats' ...},
{... 'dish soap' ...}
];
// CHALLENGE 1 //
function createFunction() {
return function(){
console.log('hello');
}
}
// UNCOMMENT THESE TO TEST YOUR WORK!
var function1 = createFunction();
///////////////////////////////////////////////////////////////////
//CHALLENGE 1//
console.log('Start of Challenge 1');
console.log('I am at the beginning of the code');
function setTimeoutFunc() {
console.log('I am in the setTimeout callback function');
}
setTimeout(setTimeoutFunc, 0);
// Challenge 1
function addTwo(num) {
return num+2
}
///////////////////////////////////////////////////////////////////////////////////////
// Challenge 2
function addS(word) {
return word + 's'
/****************************************************************
WORKING WITH OBJECT LITERALS
****************************************************************/
/*** CHALLENGE 1 of 1 ***/
function makePerson(personName, personAge) {
let newPerson = Object.create(null);
newPerson.name = personName;
newPerson.age = personAge;
return newPerson