File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
lesson_07/conditionals/src Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,12 @@ export function compareStrings(a: string, b: string): number {
1212 // if it is greater, and 0 if the strings are equal.
1313 const distance = computeLexicographicDistance ( a , b ) ;
1414
15- // TODO(you): Finish this method.
15+ if ( distance < 0 ) {
16+ return - 1 ;
17+ }
18+ if ( distance > 0 ) {
19+ return 1 ;
20+ }
1621
1722 return 0 ;
1823}
@@ -24,8 +29,10 @@ export function compareStrings(a: string, b: string): number {
2429 * @return The factorial of n.
2530 */
2631export function computeFactorial ( n : number ) : number {
27- return 0 ;
32+ if ( n === 0 ) return 1 ;
33+ return n * computeFactorial ( n - 1 ) ;
2834}
35+ console . log ( computeFactorial ( 5 ) ) ; // Output: 120
2936
3037/**
3138 * Returns an array of the first `n` Fibonacci numbers starting from 1.
You can’t perform that action at this time.
0 commit comments