Question: I have the following array:

var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35];

I want to get 15 random numbers from this array, where there can't be duplicates. I have no idea on how to do it.

Also, if it'd be easier, I would like to know if there is a way to generate an array with 15 numbers from 1 to 35, with no duplicates, instead of picking them from the array I showed.

Thanks in advance!

Answer: 
If you are just trying to get a number between 1 and 35 then you could do this, 

```
Math.floor(Math.random() * 35) + 1

```

Math.random() returns a number between 0 and 1, multiplying this by 35 gives a number between 0 and 35 (not inclusive) as a float, you then take a floor add 1 to get the desired range.

You can then loop over this and use this to populate your array.

If you don't want any repeats then I recommend you look at using a `Set` to make sure you don't have any repeats, then just loop until the set has the desired number of values.

Sets are documented [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)
Here is a simple method,. 

First create the array of numbers from 1 to 35.

Then randomly delete one from this array until the length is equal to 15.

```js
const nums = Array.from(new Array(35),(v,i)=>i+1); 
while (nums.length > 15) nums.splice(Math.random() * nums.length, 1);
console.log(nums.join(", "));
```