Ignoring the fact that this code results in an error, I can tell you the following.
var i=0;
is defining a variable namedi
to the value0
.flightprices[i]
means thei+1
th element of the arrayflightprices
.[]
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?