Remove unneeded line

the line " if (n === 0) return 1 " can be omitted, because the ' product = 1 ' and the loop won't run if  'n = 0'  and the returning result will be '1'
This commit is contained in:
Naoufal Aziane 2023-01-30 10:57:38 +01:00 committed by GitHub
parent c4301bbd9c
commit 9fe3c909b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 1 deletions

View File

@ -21,7 +21,6 @@ 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;