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 99 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
- 12,674
- 1
- 33
- 48
Hovakimyan
- 450
- 2
- 8