-
-
Save dpogue/5985869 to your computer and use it in GitHub Desktop.
Some of the JavaScript puzzlers from VanJS (2013-07-11), as presented by Charles Bihis of Adobe.
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 commodusRule = 'thumbsUp'; | |
console.log('Maximus the ' + (commodusRule === 'thumbsUp') ? 'Gladiator' : 'Merciful'); | |
// What does this print? | |
// A. "Maximus the Gladiator" | |
// B. "Maximus the Merciful" | |
// C. "Maximus the " | |
// D. None of the above |
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 name = 'World!'; | |
(function() { | |
if (typeof name === 'undefined') { | |
var name = 'Mr. Bond'; | |
console.log('Goodbye, ' + name); | |
} else { | |
console.log('Hello, ' + name); | |
} | |
})(); | |
// What does this print? | |
// A. "Hello, World!" | |
// B. "Hello, Mr. Bond" | |
// C. "Goodbye, Mr. Bond" | |
// D. "Goodbye, World!" | |
// E. None of the above |
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 doStuff(name) { | |
switch (name) { | |
case 'A': | |
console.log('It is A'); | |
break; | |
case 'B': | |
console.log('It is B'); | |
break; | |
case 'C': | |
console.log('It is C'); | |
break; | |
default: | |
console.log("We don't know!"); | |
break; | |
} | |
} | |
doStuff(new String('A')); | |
// What does this print? | |
// A. "It is A" | |
// B. "It is B" | |
// C. "It is C" | |
// D. "We don't know" | |
// E. It varies | |
// F. None of the above |
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 zipcodes = ['39461', '02391', '56910', '09154', '74512']; | |
for (var i = 0; i < zipcodes.length; i++) { | |
if (!isNaN(parseInt(zipcodes[i])) && parseInt(zipcodes[i]) > 0) { | |
console.log(parseInt(zipcodes[i])); | |
} | |
} | |
// What does this print? | |
/* A. 39461 | |
19 | |
56910 | |
74512 | |
*/ | |
/* B. 39461 | |
2391 | |
56910 | |
9154 | |
74512 | |
*/ | |
/* C. 39461 | |
56910 | |
74512 | |
*/ | |
// D. Error | |
// E. It varies | |
// F. None of the above |
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 END = 9007199254740992; // Math.pow(2, 53) | |
var START = END - 100; | |
var count = 0; | |
for (var i = START; i <= END; i++) { | |
count++; | |
} | |
console.log(count); | |
// What does this print? | |
// A. 100 | |
// B. 101 | |
// C. Error | |
// D. None of the above |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment