File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed
lesson_07/conditionals/src Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -28,9 +28,9 @@ export function compareStrings(a: string, b: string): number {
2828
2929 // TODO(you): Finish this method.
3030
31- if ( a < b ) {
31+ if ( distance < 0 ) {
3232 return - 1 ;
33- } if ( a > b ) {
33+ } if ( distance > 0 ) {
3434 return 1 ;
3535 } else {
3636 return 0 ;
@@ -95,10 +95,13 @@ export function computeFactorial(n: number): number {
9595 * @return The sum of all the values.
9696 */
9797export function addNumbers ( values : number [ ] ) : number {
98- let sum = 0
99- for ( let i = 0 ; i < values . length ; i ++ ) {
100- sum += values [ i ] ;
98+
99+ let sum = 0 ;
100+
101+ for ( const i of values ) {
102+ sum += i ;
101103 }
104+
102105 return sum ;
103106}
104107
@@ -109,14 +112,14 @@ export function addNumbers(values: number[]): number {
109112 * @return An array containing the first `n` Fibonacci values.
110113 */
111114export function getFirstNFibonacciNumbers ( n : number ) : number [ ] {
112- let array = [ n ]
115+ const array = [ n ]
113116
114117 if ( n <= 0 ) {
115118 return array ;
116119 }
117120
118121 for ( let i = 2 ; i < n ; i ++ ) {
119- let cont = array [ i - 1 ] + array [ i - 2 ] ;
122+ const cont = array [ i - 1 ] + array [ i - 2 ] ;
120123 array . push ( cont )
121124 }
122125 return array ;
You can’t perform that action at this time.
0 commit comments