I need to create an array from 0 to 60, where numbers will not repeat. Is there a method to do this in React Native?
Asked
Active
Viewed 206 times
-3
-
Possibly duplicate of this: https://stackoverflow.com/questions/5836833/create-an-array-with-random-values – Magiczne Aug 21 '20 at 10:51
1 Answers
1
You can create array with number then randomize them
const generateArr = (n) => {
const arr = []
for(let i = 0; i < n; i++){
arr.push(i)
}
return arr
}
Then you can randomize array with one of the methods described here: How to randomize (shuffle) a JavaScript array?

Sam Mason
- 15,216
- 1
- 41
- 60

Hovakimyan
- 510
- 3
- 10