I'm working on a game whereby the player selects 6 numbers between 1 - 36.
What I want to do is to make a new array that excludes the 6 selected numbers and the new array will be 30 in length.
Here is what I've done.
The first array generated:
var selectedBalls = [2, 8, 25, 13, 8, 5]; //take this as the selected balls for example
var totalBalls = [];
function getBallsReady(){
for (var i = 1; i <= 36; i++) {
totalBalls.push(i);
}
}
Here is the code I tried to get the new array, but is not perfect yet because at least 1 or 2 number(s) from the selected 6 numbers is still always part of the new array.
function generateNewBalls() {
let clonedTotalBalls = [...totalBalls];
selectedBalls.map((ball) => {
clonedTotalBalls.splice(ball, 1);
})
}
What am I doing wrong?