Skip to content

Commit

Permalink
fix: changed 'let' to 'const' on l.119 & l.126; implemented 'distance…
Browse files Browse the repository at this point in the history
…' into code on l.31 l.33; used 'for-of' loop instead of 'for' loop on l.104;
  • Loading branch information
“A1-4U2T1NN” committed Oct 11, 2024
1 parent 82381df commit a0ceba6
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lesson_07/conditionals/src/lesson7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export function compareStrings(a: string, b: string): number {

// TODO(you): Finish this method.

if(a < b){
if(distance < 0){
return -1;
} if(a > b){
} if(distance > 0){
return 1;
}else{
return 0;
Expand Down Expand Up @@ -95,10 +95,13 @@ export function computeFactorial(n: number): number {
* @return The sum of all the values.
*/
export function addNumbers(values: number[]): number {
let sum = 0
for(let i = 0; i < values.length; i++){
sum += values[i];

let sum = 0;

for(const i of values){
sum += i;
}

return sum;
}

Expand All @@ -109,14 +112,14 @@ export function addNumbers(values: number[]): number {
* @return An array containing the first `n` Fibonacci values.
*/
export function getFirstNFibonacciNumbers(n: number): number[] {
let array = [n]
const array = [n]

if(n <= 0){
return array;
}

for(let i = 2; i < n; i++){
let cont = array[i - 1] + array[i - 2];
const cont = array[i - 1] + array[i - 2];
array.push(cont)
}
return array;
Expand Down

0 comments on commit a0ceba6

Please sign in to comment.