Update calculator.js
We dont need to return 1 if n = 0 because we set the return value (product) to 1 at the first line in the function so it can not be 0. If you did this for visual reasons thats fine i just wanted to say that.
This commit is contained in:
parent
3b51e5dbef
commit
54dd398601
|
@ -21,7 +21,6 @@ function power(a, b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function factorial(n) {
|
function factorial(n) {
|
||||||
if (n == 0) return 1;
|
|
||||||
let product = 1;
|
let product = 1;
|
||||||
for (let i = n; i > 0; i--) {
|
for (let i = n; i > 0; i--) {
|
||||||
product *= i;
|
product *= i;
|
||||||
|
|
Loading…
Reference in New Issue