Skip to content

Instantly share code, notes, and snippets.

@round
Last active August 29, 2015 14:27
Show Gist options
  • Save round/33e8720bcf13b74727ac to your computer and use it in GitHub Desktop.
Save round/33e8720bcf13b74727ac to your computer and use it in GitHub Desktop.
Increment a value up and down.
var up = true;
var value = 0;
var increment = 1;
var ceiling = 100;
var floor = -100;
if (up == true && value <= ceiling) {
value += increment
if (value == ceiling)
{up = false;}
} else {
up = false
value -= increment;
if (value == floor)
{up = true;}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment