Skip to content

Commit ee9e849

Browse files
authored
Create 04-factorial.js
1 parent beda5d4 commit ee9e849

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

4-for-loop/04-factorial.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//04. Factorial
2+
3+
function factorial(n) {
4+
n = Number(n);
5+
let total = 1;
6+
for (let i = 1; i <= n; i++) {
7+
total *= i;
8+
}
9+
console.log(total);
10+
}
11+
factorial(8);

0 commit comments

Comments
 (0)