I am trying to build a table with 15 random numbers as part of a project to make the 15 puzzle game in html/javascript. I am going to insert random non-repeating numbers from an array in the first 15 spots of a table. I can't seem to get the alert with the array to work. Any help would be appreciated. Thank You!
EDIT: now i am still getting some repeating numbers. i don't understand why since im pretty sure the array is being checked for duplicates.
<script>
var arr = [];
function roll() {
for (i = 0; i < 15; i++) {
var randomNumber = Math.floor(Math.random() * 15) + 1;
if (arr.indexOf(i) != randomNumber) {
arr.push(randomNumber);
}
} alert("This Works" + arr);
}
</script>