-3

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?

Wets
  • 158
  • 1
  • 8
  • Possibly duplicate of this: https://stackoverflow.com/questions/5836833/create-an-array-with-random-values – Magiczne Aug 21 '20 at 10:51

1 Answers1

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