I'm very new to JS and I'm trying to fiddle with basic functions, as for me, the best way how to learn something is to set some project/tasks and try to find solution (at least for php, this method worked pretty well).
So I gave myself a task to create simple function but got stuck on (definitively very simple) problem.
I'm trying to make a function which would display first three elements of array onload and onclick on left/right button would move whole selection (on left click it should display last, first and second item, on right click, it should display second, third and fourth items). Basically, it would show three elements all the time and you should scroll throw them using left/right button.
As I started with JS yesterday, I don't know much (my previous experiences are simple onclick events...). This one seems more complex to me.
So far I came up with first part, which looks something like this:
var images=new Array();
<a href="#" onclick="left()">left</a>
<a href="#" onclick="right()">right</a>
My problem is that I can't come up with proper function to change the slice start/end points onclick. Can someone please just hint how the function which would decrease/increase the slice points while checking the array lenght and ensuring that the slice will jump on first/last item if it would get out of range?
I realise that the question is most likely ridiculous but for me it's not as it's my first 'practical lesson' of absolutely unknown language. Any help appreciated.
Thanks in advance