[Solved] How for loop works?


Here is an explanation of everything happening in the for loop

//                  keeps the for loop going while x is less than numbers.length which is the length of nmbers
// sets x to 0 initialy |          increases x by +1 each time it restarts to begin the loop
//       V              V            V
for (var x = 0; x < numbers.length; x++) {
    //   Executes code if numbers[x] is greater than largest
    //            V
    if (numbers[x] > largest){
        //   sets largest to numbers[x] if numbers[x] is greater than largest
        //      V
        largest = numbers[x];
    }
}

solved How for loop works?