From 0da5aa9ff6eec76f8ae83aebe6bb14da32543b1a Mon Sep 17 00:00:00 2001 From: Dev Raj Singh <55313450+devraj4522@users.noreply.github.com> Date: 2021年10月19日 19:39:02 +0530 Subject: [PATCH] Reduced and optimized code Merged two if statements --- Maths/Factorial.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Maths/Factorial.js b/Maths/Factorial.js index 29b416a67e..b68e6e27df 100644 --- a/Maths/Factorial.js +++ b/Maths/Factorial.js @@ -21,11 +21,8 @@ const calcFactorial = (num) => { if (num === 0) { return 'The factorial of 0 is 1.' } - if (num < 0) { - return 'Sorry, factorial does not exist for negative numbers.' - } - if (!num) { - return 'Sorry, factorial does not exist for null or undefined numbers.' + if (!num) || (num < 0) { + return 'Sorry, factorial does not exist for null or undefined or negative numbers.' } if (num> 0) { const range = calcRange(num)

AltStyle によって変換されたページ (->オリジナル) /