Created
January 31, 2011 15:21
-
-
Save Melipone/804177 to your computer and use it in GitHub Desktop.
Exercises in Chapter 3 of Eloquent Javascript
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
// 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