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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
function billTotal(subtotal) { | |
//input number | |
//output is number with tip and tax; | |
var tip = subtotal * 0.15; | |
var tax = subtotal * 0.095; | |
return subtotal + tip + tax; | |
} | |
function assert(actual, testName) { | |
if (!actual) { | |
console.log('FAILED ' + testName); |
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
//https://scrimba.com/casts/cNgwQA3 | |
//take array of objects; | |
//within each object; access name property: access first last prop names; | |
//return array of strings: "first last"; | |
function isTeenager(salesTeam) { | |
//return only names that are 18 and 13, inclusive; | |
//iterate through each 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
//so, Scrimba had uneccessary "unexpected token" errors that do not exist on replit. Lots of time spent debugging things that don't need debugging | |
console.log('dog'); | |
var each = function(collection, callback) { | |
if (Array.isArray(collection)) { | |
for (var i = 0; i < collection.length; i++) { | |
callback(collection[i], i, collection); | |
} | |
} else { | |
for (var key in collection) { |
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 generate = function(numRows) { | |
if (numRows === 0) { | |
return []; | |
} | |
var output = [[1]]; | |
if (numRows === 1) { | |
return output; | |
} | |
for (var i = 0; i < numRows; i++) { | |
var last = []; |
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
//which children have the largest sum node values | |
//input: node | |
//output: level of tree | |
//use breadth first search, using a cue; first in last out; | |
//edge: in case of tie, use level closest to root. | |
//sum of children; |