Last active
January 22, 2016 15:34
-
-
Save brunojppb/aaa38b5a4a867cc800c5 to your computer and use it in GitHub Desktop.
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 power = function(base, exponent) { | |
if (exponent == undefined) | |
exponent = 2; | |
var result = 1; | |
for (var count = 0; count < exponent; count++) | |
result *= base; | |
return result; | |
}; | |
console.log(power(2, 10)); | |
// → 1024 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment