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 {
28
28
29
29
// TODO(you): Finish this method.
30
30
31
- if ( a < b ) {
31
+ if ( distance < 0 ) {
32
32
return - 1 ;
33
- } if ( a > b ) {
33
+ } if ( distance > 0 ) {
34
34
return 1 ;
35
35
} else {
36
36
return 0 ;
@@ -95,10 +95,13 @@ export function computeFactorial(n: number): number {
95
95
* @return The sum of all the values.
96
96
*/
97
97
export 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 ;
101
103
}
104
+
102
105
return sum ;
103
106
}
104
107
@@ -109,14 +112,14 @@ export function addNumbers(values: number[]): number {
109
112
* @return An array containing the first `n` Fibonacci values.
110
113
*/
111
114
export function getFirstNFibonacciNumbers ( n : number ) : number [ ] {
112
- let array = [ n ]
115
+ const array = [ n ]
113
116
114
117
if ( n <= 0 ) {
115
118
return array ;
116
119
}
117
120
118
121
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 ] ;
120
123
array . push ( cont )
121
124
}
122
125
return array ;
You can’t perform that action at this time.
0 commit comments