Skip to content

Instantly share code, notes, and snippets.

View tjeastmond's full-sized avatar
🥸
Grr data

TJ Eastmond tjeastmond

🥸
Grr data
View GitHub Profile
for (var i = 1; i <= 100; ++i) {
var f = i % 3 === 0, b = i % 5 === 0;
console.log(f ? b ? 'FizzBuzz' : 'Fizz' : b ? 'Buzz' : i);
}
var isInteger = function(x) { return (x ^ 0) === x; };
function isPrime(number) {
if (typeof number !== 'number' || !isInteger(number)) {
// Alternatively you can throw an error.
return false;
}
if (number < 2) {
return false;
@tjeastmond
tjeastmond / JSModule.js
Last active October 2, 2015 08:18
JS Module Pattern - Simple example for a friend
(function() {
var SpotifySearch = window.SpotifySearch = function() {
};
}).call(this);
@tjeastmond
tjeastmond / when.js
Created March 21, 2012 20:24
Underscore.js Mixin that takes two functions as arguments, and returns a new function that when called will run the first function until it returns true. When the first function returns true, the second function is fired.
// When.js
// TJ Eastmond <tj.eastmond@gmail.com>, SpiteShow
// Simple Underscore.js Mixin that runs the first function until
// it returns true, then runs the second
(function() {
// Pass in two functions. The first is checked until it returns true, then the second is run
var when = function(truthy, func) {
// Just making sure we were passed functions...