Skip to content

Commit 6bd1f62

Browse files
Example of JS program wherein one parameter is not assigned a value.
1 parent b53c10a commit 6bd1f62

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

default_parameter.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function power(base, exponent) {
2+
if (exponent == undefined) {
3+
exponent = 2;
4+
}
5+
var result = 1;
6+
7+
for (var count = 0; count < exponent; count++) {
8+
result *= base;
9+
}
10+
return result;
11+
}
12+
13+
console.log(power(4));
14+
console.log(power(4, 3));

0 commit comments

Comments
 (0)