Last active
July 1, 2016 16:23
-
-
Save leobaiano/704b99f3847ce8c3da6a8a730e5dca93 to your computer and use it in GitHub Desktop.
Criando arrays aleatórios
This file contains hidden or 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
| function createRandomArray( lenght, max ) { | |
| return Array.apply( null, Array ( lenght ) ).map( function( _, i ) { | |
| return Math.round( Math.random() * max ); | |
| }); | |
| } | |
| console.log( createRandomArray( 20, 300 ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
const createRandomArray = (len, max) => new Array(len).fill().map(() => Math.round(Math.random() * max));