Skip to content

Instantly share code, notes, and snippets.

View zoolu-got-rhythm's full-sized avatar
🏀
ballin'

Christopher P.K. Morris zoolu-got-rhythm

🏀
ballin'
View GitHub Profile
/* TODO: minimum viable product, is just a console.log version before a DOM version.
add chicken images, onamatopia's, sounds & egg spawns.
*/
var chickPic = new Image("http://www.clker.com/cliparts/Q/7/U/E/h/1/white-chicken-hi.png");
var eggPic = new Image("http://www.pd4pic.com/images/brown-food-cartoon-eggs-egg-breakfast-chicken.png");
// function constructor
function Chicken(eggs){
this.chicken = chickPic;
this.eggs = eggs;
function Car(make, creed){
this.wheels = 4;
this.colour = "red";
this.make = make;
this.model = creed;
}
Car.prototype.getSummary = function(){
return "this car has " + this.wheels + " wheels, is " +
this.colour + ", manufactored by " + this.make + " and is a " + this.model;
function Node(node){
if(typeof node !== "string"){
throw new Error("please inset a string");
} else {
this.node = node;
}
}
var node1 = new Node("kieron");
var myNumber = 1;
function recur(n){
console.log("call stack is " + n);
n++;
n < 10 ? recur(n) : console.log("pop");
}
recur(myNumber); // only the passed number get's changed
console.log(myNumber); // the var in global scope doesn't get mutated?
public class Organism{
public Integer lifespan;
public int iq;
public String species;
// base class (super class)
public Organism(int lifespan, int iq, String species){
this.lifespan = lifespan;
this.iq = iq;
QUnit.test( "hello test", function( assert ) {
assert.ok( 1 == "1", "Passed!" );
});
QUnit.test( "truthy", function( assert ) {
assert.ok( "" == 0, "Passed!" );
});
// 50/50 test
QUnit.test( "dice", function( assert ) {
function fac(n) {
if (n == 0)
return 1;
else
return fac(n - 1) * n;
}
function arrayToList(arr){
var prevList;
var ref;
for(var i = arr.length - 1; i >= 0; i--){
if(i === arr.length - 1){
ref = null;
}else{
ref = prevList;
}
// i took a look at the author's solution after a few hrs and was defintely on the "right track"
// but realized there are a ton of ways to do this. but incrementation logic works well, where if there's a match u increment
// then u check if both numbers are the same value and call the function parsing the 2 number val's to see if there equal.
// where checking for false early in the control flow can save unneccasary computation.
function deepEqual(val1, val2){
if(typeof val1 && typeof val2 === "object" && !null){ // change to typeof maybe
console.log("ran");
@zoolu-got-rhythm
zoolu-got-rhythm / gist:efd87beff57dee392f13e9557ed70e6c
Created August 6, 2016 02:52
Subscriber pattern? how do i access methods from submodule 1 from inside submodule 2
var superModule = (function(){
// global state
return {
submodule1:{
// contains some internal state
// contains methods
},
submodule2:{
// contains some internal state