Skip to content

Instantly share code, notes, and snippets.

@macikokoro
Last active August 29, 2015 14:03
Show Gist options
  • Save macikokoro/db044e0062b5e494ff4e to your computer and use it in GitHub Desktop.
Save macikokoro/db044e0062b5e494ff4e to your computer and use it in GitHub Desktop.
For loop example
/* Syntax of a for loop:
for ( *start with this* ; *loop if this expression is true* ; *do this after each loop*) {
* in each loop, d this code!*
}
In order (initialize; check condition; control the loop) */
//Not operational cars
var carsOperational = 10;
var totalCars = 14;
for (var stoppedCar = carsOperational + 1; stoppedCar <= totalCars; stoppedCar++ ) {
console.log("Car #" + stoppedCar + " in not operational.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment