Skip to content

Instantly share code, notes, and snippets.

@Nicknyr
Last active December 9, 2017 23:41
Show Gist options
  • Save Nicknyr/09747fbbe5f31b8c7c2ed75a8187a3d4 to your computer and use it in GitHub Desktop.
Save Nicknyr/09747fbbe5f31b8c7c2ed75a8187a3d4 to your computer and use it in GitHub Desktop.
Javascript: Generate random number and push it to an array
// Generates and logs a random number between 1 and 4, pushes it to an array, and logs it
var arr = [];
function randomNumber() {
var num = Math.floor((Math.random() * 4) + 1);
arr.push(num);
console.log(arr);
}
randomNumber();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment