Skip to content

Commit a0ceba6

Browse files
author
“A1-4U2T1NN”
committed
fix: changed 'let' to 'const' on l.119 & l.126; implemented 'distance' into code on l.31 l.33; used 'for-of' loop instead of 'for' loop on l.104;
1 parent 82381df commit a0ceba6

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lesson_07/conditionals/src/lesson7.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff 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
*/
9797
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;
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
*/
111114
export 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;

0 commit comments

Comments
 (0)