I'm currently developing a game where players are required to choose 6 numbers between 1 and 36. My goal is to create a new array that does not include the 6 selected numbers, resulting in an array that is 30 numbers long.
Here is my approach:
The initial array is as follows:
var selectedNumbers = [2, 8, 25, 13, 8, 5]; // These are the chosen numbers
var allNumbers = [];
function prepareNumbers(){
for (var i = 1; i <= 36; i++) {
allNumbers.push(i);
}
}
Although I attempted to generate the new array using the code below, it is not yet perfect as it always includes at least 1 or 2 numbers from the group of selected 6 numbers.
function generateNewNumbers() {
let copiedAllNumbers = [...allNumbers];
selectedNumbers.map((number) => {
copiedAllNumbers.splice(number, 1);
})
}
What mistake am I making in this process?