mardi 10 avril 2018

Sized array of random unique numbers

I was wondering what was the most concise way to get an array of a certain size, of unique random numbers.

I get random numbers like this:

times(4, () => random(30, 95));

However this is not unique. I can filter this with uniq but I need to gurantee length of 4 of array. And I want to do it the lodash way. Any ideas?




Aucun commentaire:

Enregistrer un commentaire