From 9fe3c909b0622d13f5bc8299df2f6ea87b94b8e8 Mon Sep 17 00:00:00 2001 From: Naoufal Aziane Date: Mon, 30 Jan 2023 10:57:38 +0100 Subject: [PATCH] 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' --- calculator/calculator.js | 1 - 1 file changed, 1 deletion(-) diff --git a/calculator/calculator.js b/calculator/calculator.js index d45cc64..f8c10c9 100644 --- a/calculator/calculator.js +++ b/calculator/calculator.js @@ -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;