How can I remove a special number from array in this example. I have 9 numbers in array nums and empty array narr. I want to delete a random index (let rand) from nums and add this to narr. In narr pushing is correct but when i tried delete the same number from nums by pop, splice, slice etc it didn't correct answer. Which metod should i use?
function sudoku(arr){
let nums = [1,2,3,4,5,6,7,8,9];
let narr = [];
for(let i = 0; i<9; i++){
let rand = Math.floor(Math.random()*nums.length);
narr.push(nums[rand]);
nums.pop(nums[rand]);
}
return narr;
}