A little recursive function:
getNum() {
let randomNum = Math.floor(Math.random() * (30 - 1)) + 1
if (list.includes(randomNum)) {
return getNum()
}
return randomNum
}
Might be a little faster, since it first tries to return a random number, and then checks if it's in the array.