View test.js
function test() {
assert.shouldEqual(factorial(0), 1);
assert.shouldEqual(factorial(1), 1);
assert.shouldEqual(factorial(2), 2);
assert.shouldEqual(factorial(6), 1);
assert.shouldEqual(factorial(10), 3628800);
assert.shouldEqual(factorial(12), 479001600);
assert.shouldEqual(factorial(18), 6402373705728000);
// Throw error for factorials greater than 18
View array.flatten.js
'use strict';
/**
* Flattens a deep-nested array of integers (numbers)
* @param {Number[]} inpArray A possibly deep-nested array of numbers.
* The level of nesting is limited by the maximum stack size of the
* JavaScript engine (the lowest we have seen is IE6 at 1130)
* @return {Number[]} Returns a flattened version of the input array
*/
function flatten (inpArray) {
View nextTick.js
for (var i = 0; i < 1024 * 1024; i++) {
process.nextTick(function () { Math.sqrt(i) } )
}