javascript - Why is getRandimInt returning undefined? -
i have array name winarr .
let winarr = [[[1,2],[3,6],[4,8]], [[0,2],[4,7]], [[0,1],[4,6],[5,8]], [[0,6],[4,5]], [[0,8],[1,7],[2,6],[3,5]], [[2,8],[3,4]], [[0,3],[2,4],[7,8]], [[1,4],[6,8]], [[0,4],[2,5],[6,7]] ] ;
now generating random integer 0 8. don't want got.
function getrandomint(min, max) { min = math.ceil(min); max = math.floor(max); let ranint = math.floor(math.random() * (max - min)) + min; if(winarr[ranint] === null) { getrandomint(min,max) ; } else { winarr[ranint] = null ; return ranint ; } }
i call function 9 times want different 9 integers getrandomint(0,8) ;
each time. function returning undefined
.
change
getrandomint(min,max) ;
to
return getrandomint(min, max);
Comments
Post a Comment