FUNdaMENTALS
HTML
<div class="results" id="results"></div>
CSS
.results {
width:100%;
}
.divider {
border-bottom:1px dotted black;
}
.success {
background: green;
}
.fail {
background: red;
}
JavaScript
//showing some basic expressions and syntax
assertTrue(true, 'true is true...');
assertFalse(false, 'false is false');
assertTrue(1 > 0, '1 > 0');
assertTrue(1 + 3 === 4, '1 + 3 === 4');
assertTrue('bat' + 'man' === 'batman', '\'bat\' + \'man\' === \'batman\'');
assertFalse(undefined, 'undefined is false');
assertFalse(null, 'null is false');
//This is how to declare a variable
var basic;
assertTrue(basic === undefined, 'basic is undefined');
//assignment
basic = 1;
assertTrue(basic === 1, 'basic equals 1');
assertTrue(typeof typeof basic === 'string', 'typeof returns strings');
//All variables can be any type... Both awesome and scary
basic = 'I used to be one, but only for a year';
assertTrue(typeof basic === 'string', 'basic is now a string');
basic = true;
assertTrue(typeof basic === 'boolean' && basic, 'basic is truly true');
//Some basic function syntax and behavior
//Function declaration: function hoisting makes it so we can reference this available before and after //its declaration. Cool!
//http://lmgtfy.com/?q=javascript+function+hoisting
assertTrue(typeof foo === 'function', 'foo is a function before the declaration');
function foo() {
return 'sball';
};
assertTrue(typeof foo === 'function', 'foo is a function after its declaration');
assertTrue(foo() === 'sball', 'foo gives up bar');
//Assigning a different function to the same variable using a different means of declaring the function
//This is a function expression versus a declaration. It would not be referenceable before and after it because it doesn't get the benefit of function hoisting.
var foo = function () {
return 'bar';
};
assertTrue(foo() === 'bar' && foo() !== 'sball', 'Overwriting a function variable with a different function is just dandy');
//Function hoisting can create weird situations if you aren't careful.
var tickTick =...