Update calculator.js

Cleaned up the for loop.
This commit is contained in:
Alejandro Hernandez 2022-08-30 01:14:16 -07:00 committed by GitHub
parent db998d7279
commit 2f8473cbdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 3 deletions

View File

@ -23,9 +23,7 @@ const power = function(a, b) {
const factorial = function(n) {
if (n === 0) return 1;
let product = 1;
for (let i = n; i > 0; i--) {
product *= i;
}
for (n; n > 0; n--) product *= n;
return product;
};