I need this code to return a different value (from 0 to 14) if its not defined in my array. I dont understan why it tells me that "n" is not defined. please help
EDIT ***
I fixed the n value, but I’m still getting numbers that are included in my array !!
EDIT 2 *******
I need my code to return a numerical value (at random) that is not included in my array. This is a simplified version of what I’m doing, the full version has non sequential values and a lot of numbers!!
function test () {
var arr= [1,2,3,4,5,6,7,8,9];
var n = Math.floor((Math.random() * 15));
var tex = $.inArray( n, arr );
if (tex == -1) {
return n;
}
else {
var n = Math.floor((Math.random() * 15));
}
alert (n);
}