mirror of
https://github.com/10h30/odin-javascript-exercises.git
synced 2026-07-11 18:55:59 +09:00
Update fibonacci-solution.js
This commit is contained in:
@@ -4,13 +4,11 @@ const fibonacci = function(count) {
|
|||||||
|
|
||||||
let firstPrev = 1;
|
let firstPrev = 1;
|
||||||
let secondPrev = 0;
|
let secondPrev = 0;
|
||||||
|
|
||||||
// For clarification: curr stands for current. This is standard syntax
|
|
||||||
|
|
||||||
for (let i = 2; i <= count; i++) {
|
for (let i = 2; i <= count; i++) {
|
||||||
let curr = firstPrev + secondPrev;
|
let current = firstPrev + secondPrev;
|
||||||
secondPrev = firstPrev;
|
secondPrev = firstPrev;
|
||||||
firstPrev = curr;
|
firstPrev = current;
|
||||||
}
|
}
|
||||||
|
|
||||||
return firstPrev;
|
return firstPrev;
|
||||||
|
|||||||
Reference in New Issue
Block a user