Last active
December 9, 2017 23:41
-
-
Save Nicknyr/09747fbbe5f31b8c7c2ed75a8187a3d4 to your computer and use it in GitHub Desktop.
Javascript: Generate random number and push it to an array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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