# Fibonacci sequence - position

**URL:** <https://forum.freecodecamp.org/t/fibonacci-sequence-position/326739>\
**Category:** General\
**Created:** [November 18, 2019, 4:42pm UTC](https://forum.freecodecamp.org/t/fibonacci-sequence-position/326739 "2019-11-18T16:42:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![camcode](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/camcode/32/113316_2.png) [@camcode](https://forum.freecodecamp.org/u/camcode)\
**Post date:** [November 18, 2019, 4:42pm UTC](https://forum.freecodecamp.org/t/fibonacci-sequence-position/326739/1 "2019-11-18T16:42:29Z")

</div>

I search something about recursionl, in particular Fibonacci sequence and I see this example:

```auto
var fibonacci_series = function (n) 
{
  if (n===1) 
  {
    return [0, 1];
  } 
  else 
  {
    var s = fibonacci_series(n - 1);
    s.push(s[s.length - 1] + s[s.length - 2]);
    console.log(s[s.length -1]); // add me
    console.log(s[s.length -2]); // add me
    return s;
  }
};

 console.log(fibonacci_series(8));

```

and I don’t understand what means` s[s.length -1]` and `s[s.length-2]`, I mean they represent the positions or other things.  
If it presents the positions which one does it take?  
Or there’s something that escapes me and I can’t see.  
P.S  
I ask if there is any resource that explains it in a simple step by step manner.  
Thanks,  
CamCode

---

<div class="post-metadata">

**Author:** ![camcode](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/camcode/32/113316_2.png) [@camcode](https://forum.freecodecamp.org/u/camcode)\
**Post date:** [November 18, 2019, 5:04pm UTC](https://forum.freecodecamp.org/t/fibonacci-sequence-position/326739/3 "2019-11-18T17:04:08Z")

</div>

When I looked at that line of code, I think this:  
If i get for example 3 as parameter of function,  
executes the function, arrives at the variable s,that recall function ,but  
instead having 3 now I have 2 (if I do n -1),then it goes on until it reaches 1.  
Arrived at the line `s.push(s[s.length - 1] + s[s.length - 2]);`  
I had thought it was making the sum and add element in s.  
(I don’t know if I’m thinking well here)

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 11:32am UTC](https://forum.freecodecamp.org/t/fibonacci-sequence-position/326739/4 "2021-01-16T11:32:43Z")

</div>


