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
/* | |
Given a JavaScript array, function flattens the array and returns the sum of all primitive-type numbers in the array. | |
The function works recursively. | |
*/ | |
function flattenAndAdd(arrayToFlatten) { | |
var originalArray = arrayToFlatten; | |
var repeat = 1; |
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
/* | |
I created a Google Sheet to organize short bursts of lesson plan content across grade and content levels at Dever School. | |
Script automatically deletes out-of-date entries. | |
Script will also sort the page after deleting duplicates so that up-to-date information appears first. | |
*/ | |
function removeDuplicates(){ | |
Logger.clear(); | |
Logger.log("starting over..."); | |
var ss = SpreadsheetApp.openById(**ID NUMBER HERE **); //get spreadsheet |
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
{ | |
"name" : "Fun Song", | |
"instruments" : { | |
"funSound" : { | |
"sources" : { | |
"1" : "sine", | |
"2" : "sine", | |
}, | |
"envelope": { | |
"attack" : 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
// In a recent interview I was stumped by a question about JS's native | |
// function.apply() and function.call() methods. I resolved to learn more | |
// about why these methods are useful to a JS developer. Here's what I now | |
// understand: | |
// let's make a simple function that introduces an individual. | |
// We pass arguments defining the interests of the individual. | |
// The greeting is personalized by the value of this.name. | |
function introduceMe (interest1, interest2) { | |
var that = this; |
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
var | |
vowels = ['a', 'e', 'i', 'o', 'u', 'y'], | |
consonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z'], | |
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; | |
function name (nameLength, numberOfNames) { | |
var names = []; | |
if (nameLength > 14) return 'too long!'; | |
if (numberOfNames > 100 || numberOfNames < 0 || typeof numberOfNames !== 'number') numberOfNames = 1; | |
var |
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
Array.prototype.rammstein = function () { | |
var phrase = '', rammsteined = []; | |
this.forEach( function ( word ) { | |
phrase += word.toUpperCase() + ' '; | |
rammsteined.push( phrase ); | |
}); | |
return rammsteined; | |
} |
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
Array.prototype.fakeMap = function (fn, context) { | |
var out = this instanceof Array ? [] : {}, | |
context = context || this, | |
result, | |
n; | |
if (typeof fn !== "function") { | |
return []; | |
} | |
for (n in this) { | |
if (this.hasOwnProperty(n)) { |
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 isPalindrome (str) { | |
if (typeof str !== 'string') { | |
return false; | |
} | |
var n, | |
letters = str.split(''), | |
len = letters.length - 1; | |
for (n = 0; n <= len; n++) { | |
if (n !== len - n && letters[n] !== letters[len - n]) { | |
return false; |
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
// in order for this to work, you need a yummly dev account. | |
function makePie (response) { | |
var match = JSON.parse(response).matches[0], | |
yourPie = ["you could bake a delicious ", | |
match.recipeName, | |
" using "]; | |
match.ingredients.forEach(function (ingredient) { | |
yourPie.push("[" + ingredient + "]"); | |
}); |
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
#!/bin/sh | |
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".js\{0,1\}") | |
if [[ "$STAGED_FILES" = "" ]]; then | |
exit 0 | |
fi | |
PASS=true |
OlderNewer