i would like to generate random numbers from 1-50, then exclude an array like; 4,7,10,20,35 etc
i tried this;
let mainNum = 50
let exclNum = [4, 7, 10, 20, 35];
if (!exclNum.includes(mainNum)) {
console.log(Math.floor(Math.random() * mainNum) + 1)
}
but it still generates numbers that's still in the array, please is there anything i am missing?
Thanks for your response in advance
Aucun commentaire:
Enregistrer un commentaire