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 stepSum() { | |
var total = 0; | |
for (var i = 0; i < arguments.length; i++) { | |
var parameter = arguments[i]; | |
if (typeof(parameter) !== 'number') { | |
parameter = parseInt(parameter); | |
} | |
setTimeout(function() { | |
if (!isNaN(parameter)) { | |
total += parameter; |
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
// example using the raf module from npm. try changing some values! | |
var requestAnimationFrame = require("raf") | |
var canvas = document.createElement("canvas") | |
canvas.width = 500 | |
canvas.height = 500 | |
document.body.appendChild(canvas) | |
var context = canvas.getContext("2d") |
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 MyItemView = VDOMItemView.extend({ | |
template: _.template('<p><a><b>w<%= content %></b></a></p>'), | |
modelEvents: { | |
"change": "render" | |
} | |
}); |
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
describe('the preCondition instruction', function () { | |
var counter1 = 0, | |
counter2 = 0, | |
interval; | |
beforeEach(function(done) { | |
interval = setInterval(function(){ | |
counter1 += 100; | |
}, 100); |
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://www.interviewcake.com/question/javascript/graph-coloring | |
Given an undirected graph with maximum degree D, find a graph coloring using at most D+1 colors. | |
Our solution runs in O(N+M)O(N+M) time but takes O(D)O(D) space. Can we get down to O(1)O(1) space? | |
*/ | |
function GraphNode(label) { | |
this.label = label; | |
this.neighbors = new Set(); |