Skip to content

Instantly share code, notes, and snippets.

@bcrescimanno
bcrescimanno / gist:6830318
Last active December 24, 2015 16:49
BETTER solution to You Can't JavaScript Under Pressure Question 5
function acc(pV, cV) {
if (cV instanceof Array) {
return pV + cV.reduce(acc, 0);
} else if (typeof cV == 'number') {
return pV + cV;
}
}
function arrSum(i) {
return i.reduce(acc, 0);
@bcrescimanno
bcrescimanno / gist:6830270
Created October 4, 2013 18:18
"Typical" solution for You Can't JavaScript under pressure Step 5
function monkey(arr) {
var len = arr.length,
cur,
finalVal = 0,
i;
for (i = 0; i < len; i++) {
cur = arr[i];
if (cur instanceof Array) {
finalVal += monkey(cur);
@bcrescimanno
bcrescimanno / gist:5144215
Created March 12, 2013 16:12
Javascript tabbing errors
function testing () {
var test = 'something'
, testing
, someother
;
// Cursor at correct position
var something,
yes, // Had to manually tab this line over