Skip to content

Instantly share code, notes, and snippets.

@leobaiano
Last active July 1, 2016 16:23
Show Gist options
  • Save leobaiano/704b99f3847ce8c3da6a8a730e5dca93 to your computer and use it in GitHub Desktop.
Save leobaiano/704b99f3847ce8c3da6a8a730e5dca93 to your computer and use it in GitHub Desktop.
Criando arrays aleatórios
function createRandomArray( lenght, max ) {
return Array.apply( null, Array ( lenght ) ).map( function( _, i ) {
return Math.round( Math.random() * max );
});
}
console.log( createRandomArray( 20, 300 ) );
@eduardonunesp
Copy link

const createRandomArray = (len, max) => new Array(len).fill().map(() => Math.round(Math.random() * max));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment