Adsaqw loop qwokqw

asdas fasdkoe lpaplasas

You don’t see the log messages because the while loop never gets into the loop—the condition that you specified is always false.

movies[0] returns the first object inside the array, and it will always return false if you compare to the length of the array. :slight_smile:

You need an index to iterate over the movies array. The array is also zero-indexed so you go from 0 to length-1. Something like:

var index = 0;
while (index < movies.length) {
  var current = movies[index];
  if (current.hasWatched != true) { ... } else { ... }
  index++;
}
1 Like

replace

console.log("You have not seen " + movies.title + " - " + movies.stars + " stars.")

with

console.log("You have not seen " + current.title + " - " + current.stars + " stars.")

you incremented the movies instead of the index
you could also swap the the result so you don’t have to use != operand

var i = 0;
while(i < movies.length) {
  if(movies[i].hasWatched){
    console.log('You have seen '+movies[i].title+' - '+movies[i].stars+'stars.')
  }else{
    console.log('You have not seen '+movies[i].title +' - '+movies[i].stars+'stars.')
  }
  i++;
}

PS: i got consfused, didn’t notice which answer you were following. disregard my answer…

1 Like