educative.io

Why argument is passed on the decrementIndex function whereas the function definition doesnt accepts an argument?

var decrementIndex = function(){
//console.log(currentIndex);
currentIndex = currentIndex - 1;
if (currentIndex < 0) {currentIndex = images.length - 1}
return currentIndex;
}

prev.onclick = function(){
  img.setAttribute('src', images[*decrementIndex(currentIndex)*]);  
}


----
Type your question above this line.

Course: https://www.educative.io/collection/10370001/5686791109607424
Lesson: https://www.educative.io/collection/page/10370001/5686791109607424/5759778777202688

Hi @Siddhant_Agarwal, Functions in javascript are inherently vardiac (it can accept a variable number of arguments). It shows the dynamic behavior of Javascript.