This file contains hidden or 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
[4mRunning "simplemocha:all" (simplemocha) task[24m | |
1..1 | |
ok 1 Array indexOf() should return -1 when the value is not present | |
# tests 1 | |
# pass 1 | |
# fail 0 | |
[32mDone, without errors.[39m |
This file contains hidden or 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 puzzlers = [ | |
function ( a ) { return 8*a - 10; }, | |
function ( a ) { return (a-3) * (a-3) * (a-3); }, | |
function ( a ) { return a * a + 4; }, | |
function ( a ) { return a % 5; } | |
]; | |
alert( puzzlers[ puzzlers[1](3) ]( puzzlers[3](9) ) ); |
This file contains hidden or 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 puzzlers = [ | |
function ( a ) { return 8*a - 10; }, | |
function ( a ) { return (a-3) * (a-3) * (a-3); }, | |
function ( a ) { return a * a + 4; }, | |
function ( a ) { return a % 5; } | |
]; | |
var start = 2; | |
var applyAndEmpty = function( input, queue ) { | |
var length = queue.length; |
This file contains hidden or 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 adventureSelector ( userChoice ) { | |
if (userChoice == 1) { | |
return function () { | |
alert("You've selected the Vines of Doom!\n" + | |
"Hope you have a swingin' time."); | |
}; | |
} else if (userChoice == 2) { | |
return function () { | |
alert("Looks like you want the Lake of Despair!\n" + | |
"Watch out for crocs. And I ain't talkin' about shoes."); |
This file contains hidden or 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 modifiedNames = [ "Thomas Meeks", | |
"Gregg Pollack", | |
"Christine Wong", | |
"Dan McGaw" ]; | |
modifiedNames.map(function(cell){ alert("Yo, " + cell + "!");}); | |
//alerts Yo, name! |
This file contains hidden or 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 passengers = [ ["Thomas", "Meeks"], | |
["Gregg", "Pollack"], | |
["Christine", "Wong"], | |
["Dan", "McGaw"] ]; | |
var modifiedNames = passengers.map(function(cell){ return cell[0] + ' ' + cell[1];}); | |
console.log(modifiedNames); | |
//This will log: ["Thomas Meeks", "Gregg Pollack", "Christine Wong", "Dan McGaw"] |
This file contains hidden or 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 numbers = [12, 4, 3, 9, 8, 6, 10, 1]; | |
var results = numbers.map(function(arrayCell) {return arrayCell * 2;}); | |
console.log(results); |
This file contains hidden or 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 greeting; | |
newCustomer = true;//change to false or true for diff result. | |
if(newCustomer){ | |
greeting = function() { | |
alert("Thanks for visiting our site!\n" + "Discover our content!"); | |
}; | |
} else { | |
greeting = function() { | |
alert("Welcome back!\n" + "We have new content for you!"); |
This file contains hidden or 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 totalGen = 19; | |
var totalMW = 0; | |
var totalGen = 19; | |
var totalMW = 0; | |
for (var gen = 1; gen <= totalGen; gen++) { | |
if (gen % 2 != 0) { | |
console.log("Generator #" + gen + " is off."); |
This file contains hidden or 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 numSheep = 4; | |
var monthsToPrint = 12; | |
for (var monthNumber = 1; monthNumber <= monthsToPrint; monthNumber++) { | |
if (monthNumber % 4 === 0) { | |
numSheep = numSheep / 4; | |
console.log("Removing " + numSheep * 3 + " sheep from the population. Phew!"); | |
} else if (numSheep > 10000) { | |
numSheep = numSheep / 2; |