I'm trying to follow the tutorial, and create own function to populate the array. I use codepen environment for this.
Here is the link http://codepen.io/Aya84/pen/pbBjbx
Here is the code:
I declared empty array like:
var listEl = [ ];
and then tried to fill it, through the console call
listEl = addElement(1, listEl);
listEl = addElement(2, listEl);
And it doesn't work at all. It returns undefined on the first call, and then it return errors on the second.
Please help me to figure out, where I'm wrong.
UPDATE: The function works fine, when array is NOT empty, and already has some existing elements in it. However it doesn't work, when array is empty, and cannot push the first element to it.