We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1e8fa55 commit 9c1d5c5Copy full SHA for 9c1d5c5
lesson_07/conditionals/src/lesson7.ts
@@ -22,11 +22,11 @@ export function compareStrings(a: string, b: string): number {
22
* Computes the factorial of the given value of `n`.
23
*
24
* @param n The value for which to compute the factorial.
25
- * @return The factorial of n.
+ * @return The factorial of n, or 0 if n is negative.
26
*/
27
export function computeFactorial(n: number): number {
28
if (n < 0) {
29
- throw new Error("Factorial is not defined for negative numbers.");
+ return 0; // Return 0 for negative numbers as per the test case
30
}
31
if (n === 0 || n === 1) {
32
return 1;
0 commit comments