File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
lesson_07/conditionals/src Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -11,10 +11,15 @@ export function compareStrings(a: string, b: string): number {
11
11
// The distance will be a number less than 0 if string `a` is lexicographically less than `b`, 1
12
12
// if it is greater, and 0 if the strings are equal.
13
13
const distance = computeLexicographicDistance ( a , b ) ;
14
-
15
14
// TODO(you): Finish this method.
16
15
17
- return 0 ;
16
+ if ( distance < 0 ) {
17
+ return - 1 ;
18
+ } else if ( distance > 0 ) {
19
+ return 1 ;
20
+ } else {
21
+ return 0 ;
22
+ }
18
23
}
19
24
20
25
/**
@@ -24,7 +29,11 @@ export function compareStrings(a: string, b: string): number {
24
29
* @return The factorial of n.
25
30
*/
26
31
export function computeFactorial ( n : number ) : number {
27
- return 0 ;
32
+ let result : number = n ;
33
+ for ( let i = result ; i > 0 ; i -- ) {
34
+ result = i * ( i - 1 ) ;
35
+ }
36
+ return result ;
28
37
}
29
38
30
39
/**
You can’t perform that action at this time.
0 commit comments