-
-
Save 0Prime/b453b5d6906f0e9d25d28fcc2b1a804b 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