Skip to content

Instantly share code, notes, and snippets.

@jakeboxer
Created April 27, 2014 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakeboxer/11337845 to your computer and use it in GitHub Desktop.
Save jakeboxer/11337845 to your computer and use it in GitHub Desktop.
// Random
var numberToAdd = Math.floor(Math.random() * 50);
var array = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50];
if (array.indexOf(numberToAdd) >= 0) {
console.log(numberToAdd + " is already in the array, ignoring...");
} else {
console.log(numberToAdd + " isn't in the array, adding...")
array.push(numberToAdd);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment