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
// Simple problems to solve using the native .reduce and .map array methods. Each of these problems can be solved in many | |
// different ways, but try to solve them using the requested higher order function. | |
// MAP | |
// Write a function capitalize that takes a string and uses .map to return the same string in all caps. | |
// ex. capitalize('whoop') // => 'WHOOP' | |
// ex. capitalize('oh hey gurl') // => "OH HEY GURL" | |
var capitalize = function(string){ | |
// code code code! |
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
{"type":"match","offset":0,"text":"(a|b)","body":[ | |
{"type":"capture-group","offset":1,"text":"a|b","body": | |
{"type":"alternate","offset":1,"text":"a|b","left": | |
{"type":"match","offset":1,"text":"a","body":[ | |
{"type":"literal","offset":1,"text":"a","body":"a","escaped":false} | |
]},"right": | |
{"type":"match","offset":3,"text":"b","body":[ | |
{"type":"literal","offset":3,"text":"b","body":"b","escaped":false} | |
]} | |
},"index":1}, |
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
// This is an example of a simplified javascript hash table that showcases a neat way (ln 64) to remove entries without | |
// unneccesary iteration and without leaving undefined values lying around. | |
// I was too lazy to write a real hashing function, so just pretend that the hash function shown at the bottom works perfectly | |
var makeHashTable = function(){ | |
var result = {}; | |
result.storage = []; | |
var storageLimit = 10; |
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
// This function does not return anything, but instead creates a new instance of an object with | |
// the given attributes when the "new" keyword is used. | |
var Cat = function(){ | |
this.stomach = []; | |
}; | |
// adds methods to the prototype for this new cat object | |
Cat.prototype.meow = function(){ | |
console.log("MEOWPURR"); | |
}; |
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
// Creates a basic cat with meow and eat methods, then creates a kitten object that inherits from | |
// Makes cats with meow and eat methods, plus a stomach (just for hairballs) | |
var makeCat = function(name){ | |
var cat = Object.create(catMethods); | |
cat.stomach = []; | |
return cat; | |
}; |
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
// Makes two animals that have their own animal sound methods, but share a common .eat method | |
var makeCat = function(){ | |
var cat = {}; | |
cat.stomach = []; | |
cat.meow = function(){ | |
console.log("MEOW"); | |
}; | |
_.extend(cat, animalMethods); |
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
var makeCat = function(){ | |
var cat = {}; | |
cat.stomach = []; | |
cat.meow = function(){ | |
console.log("MEOW"); | |
}; | |
cat.eat = function(food){ | |
cat.stomach.push(food); |
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
### Keybase proof | |
I hereby claim: | |
* I am tessmyers on github. | |
* I am tessmyers (https://keybase.io/tessmyers) on keybase. | |
* I have a public key whose fingerprint is D6EB 9A97 99A7 EFAC 31CB 1D9B 6AAD E366 07AD 4048 | |
To claim this, I am signing this object: |
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
var checkPassword = function() { | |
var query = prompt("what's the password?"); | |
if(query === "password"); { | |
alert("Awesomesauce, that's right!"); | |
} else {checkPassword()} | |
} | |
} | |
} |