This file contains 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
/* 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; |
This file contains 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 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; |
This file contains 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 Node(node){ | |
if(typeof node !== "string"){ | |
throw new Error("please inset a string"); | |
} else { | |
this.node = node; | |
} | |
} | |
var node1 = new Node("kieron"); |
This file contains 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 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? |
This file contains 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
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; |
This file contains 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
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 ) { |
This file contains 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 fac(n) { | |
if (n == 0) | |
return 1; | |
else | |
return fac(n - 1) * n; | |
} |
This file contains 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 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; | |
} |
This file contains 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
// 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"); |
This file contains 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 superModule = (function(){ | |
// global state | |
return { | |
submodule1:{ | |
// contains some internal state | |
// contains methods | |
}, | |
submodule2:{ | |
// contains some internal state |
OlderNewer