How to remove a variable after it in the same function?

I have a function that displays images when you click on them. When called, we pass it the sequence number of the image src and how many images.
When you click on the right arrow show the next image, left for previous.

$('> .lb-nav > .lb-prev', ts.lb_container).click(function(){
 if(option.index == 1)
return;
self.LightBox({
 source: source,
 index: option.index - 1,
 last_index: option.last_index});
console.log(option.index);
});

 //transition kartinku
 $('> .lb-nav > .lb-next' ts.lb_container).click(function(){
 if(option.index == option.last_index)
return;
self.LightBox({
 source: source,
 index: option.index + 1,
 last_index: option.last_index});
console.log(option.index);
 });


LightBox - this is the same function. It again has the same handlers.

Here is the problem - after 2 clicks the variables are stored and the output is not 1 time, and ascending , with duplicate indexes.
53970f6f73be4079bf2a3c519e36b463.png
How to fix it?
July 8th 19 at 16:45

Find more questions by tags JavaScriptjQuery