Whats wrong with this code i want to disable the the buttons but its not working

nextBtn.addEventListener('click', function(){
   currentItem++
   if(currentItem > reviews.length){
     currentItem.disabled = true
   }
})

prevBtn.addEventListener('click', function(){
  currentItem--

  if(currentItem === 0){
    prevBtn.disabled = true
  }
})
1 Like

guys i want to disable next button when it greater the array.lenght and disable the previous button when it in the starting point

1 Like

Hi the problem is in the line 4 of your code that your trying to disable the currentItem which is a number not an element you also wrote correct code in second function. I suggest also use else in both functions to be dynamic in the first one your should enable prevBtn and the second func vice versa hope it helps I tried to not mention the solution directly.