Skip to content

Instantly share code, notes, and snippets.

@Melipone
Created January 31, 2011 15:21
Show Gist options
  • Save Melipone/804177 to your computer and use it in GitHub Desktop.
Save Melipone/804177 to your computer and use it in GitHub Desktop.
Exercises in Chapter 3 of Eloquent Javascript
// Exercise 3.1
function absolute (num) {
if (num >= 0)
return num;
return (- num);
}
// I realize that testing the other branch first is more efficient
// Exercise 3.2
function greaterThan (num) {
function theTest (anum) {
return (anum > num);
}
return theTest;
}
var mytest = greaterThan (5);
mytest(3);
mytest(6);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment