Skip to content

Commit df6090a

Browse files
authored
Update js codes.docx
1 parent c9da137 commit df6090a

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

js codes.docx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,15 @@ var arr = [0, 1]
345345
return arr
346346
}
347347
console.log(listFibonacci(4))
348+
-----------------------------------------------------------------------
349+
function listFibonacci(n) {
350+
var arr = [0, 1]
351+
for (var i = 0; i < n; i++)
352+
arr.push(arr[i] + arr[i + 1])
353+
354+
return arr
355+
}
356+
console.log(listFibonacci(4))
348357
================================================================================================================================================================================
349358
Code 26: Finding a missing elements in an array and then add with existing elements. (-1 means if elements not found then it will return always -1 as per rule)
350359
function missingElement(){

0 commit comments

Comments
 (0)