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 {
1111 // The distance will be a number less than 0 if string `a` is lexicographically less than `b`, 1
1212 // if it is greater, and 0 if the strings are equal.
1313 const distance = computeLexicographicDistance ( a , b ) ;
14-
1514 // TODO(you): Finish this method.
1615
17- return 0 ;
16+ if ( distance < 0 ) {
17+ return - 1 ;
18+ } else if ( distance > 0 ) {
19+ return 1 ;
20+ } else {
21+ return 0 ;
22+ }
1823}
1924
2025/**
@@ -24,7 +29,11 @@ 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+ let result : number = n ;
33+ for ( let i = result ; i > 0 ; i -- ) {
34+ result = i * ( i - 1 ) ;
35+ }
36+ return result ;
2837}
2938
3039/**
You can’t perform that action at this time.
0 commit comments