[Solved] What does double brackets mean in this condition?


Ignoring the fact that this code results in an error, I can tell you the following.

  • var i=0; is defining a variable named i to the value 0.
  • flightprices[i] means the i+1th element of the array flightprices. [] notation is an array selector. Because JavaScript is 0-indexed, flightprices[0] means the first element, flightprices[1] is the second element, and so on.

Why there is an error

This line:

if (flightprices.length[i].checked) {

tries to find element i of flightprices.length, however the length of something is always an integer, and integers aren’t arrays.

3

solved What does double brackets mean in this condition?