Skip to content

Instantly share code, notes, and snippets.

@macikokoro
Last active August 29, 2015 14:03
Show Gist options
  • Save macikokoro/a5b55668241156c671e4 to your computer and use it in GitHub Desktop.
Save macikokoro/a5b55668241156c671e4 to your computer and use it in GitHub Desktop.
While loop and for loop combo.
var totalCars = 10;
var carsOperational = 8;
var carNumber = 1;
while(carNumber <= carsOperational) {
console.log("Car #" + carNumber + " is running.");
carNumber++;
}
for( var stoppedCar = carsOperational + 1; stoppedCar <= totalCars; stoppedCar++) {
console.log("Car# " + stoppedCar + " is not operational.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment