Skip to content

Commit 51070a9

Browse files
author
“A1-4U2T1NN”
committed
feat: added condition for 'if (n <= 0){}
1 parent 42534de commit 51070a9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lesson_07/conditionals/src/lesson7.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,12 @@ export function addNumbers(values: number[]): number {
116116
*/
117117
export function getFirstNFibonacciNumbers(n: number): number[] {
118118

119-
const array = [n]
120-
if (n == 0){
121-
return array;
119+
const array = [1,1]
120+
121+
if (n <= 0){
122+
return [];
123+
}else if(n === 1){
124+
return [1]
122125
}
123126
for(let i = 2; i < n; i++){
124127
const cont = array[i - 1] + array[i - 2];

0 commit comments

Comments
 (0)