[Vuejs]-My Function is only looping once before it breaks out. How can i fix this? Vuejs

0👍

Here this.currentCart.items.length > i:

  for(var i=0; this.currentCart.items.length > i; i++){

It looks like this is incorrect. Try doing this.currentCart.items.length <= i since this is the expression that gets evaluated if the for loop should run again.

You want to keep running the loop while i is less than the length of the array, not while i is greater than the length of the array (since i starts at 0 it can never be greater than the length of the array and so your loop never runs).

Leave a comment