Skip to content

Instantly share code, notes, and snippets.

@macikokoro
Created August 2, 2014 04:08
Show Gist options
  • Save macikokoro/5cb92790f20b21e02632 to your computer and use it in GitHub Desktop.
Save macikokoro/5cb92790f20b21e02632 to your computer and use it in GitHub Desktop.
Example of calling a function expression with console.log.
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.");
};
} else if (userChoice == 3) {
return function () {
alert("The Caves of Catastrophe, really?\n" +
"Alright, well....nice knowing you.");
};
}
}
console.log(adventureSelector(3)());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment