Created
April 29, 2017 20:44
-
-
Save gpbaculio/d76022b1e0894507c0038b993cbd29db to your computer and use it in GitHub Desktop.
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
// alert requires only one argument, the 2nd and 3rd arguments are ignored and alerts only "Hello" | |
alert("Hello", "Good Evening", "How do you do?"); | |
function power(base, exponent) { | |
if (exponent == undefined) { | |
debugger; | |
exponent = 2; | |
} | |
var result = 1; | |
for (var count = 0; count < exponent; count++) { | |
debugger; | |
result *= base; | |
} | |
return result; | |
} | |
console.log(power(4)); | |
// passing only one argument will result exponent to have undefined value, so the if block condition is met, assigning 2 to exponent | |
// → 16 | |
console.log(power(4, 3)); | |
// → 64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment