var a=new Array;
for (j=0;j<=10;j++) {
a[j]=Math.floor(Math.random()*99)+2
}
var check=Math.floor(Math.random()*99)+2
So how do I check whether check
is a value of any of the a[j]
(that is a[0]
to a[10]
)? A good and simple method?
var a=new Array;
for (j=0;j<=10;j++) {
a[j]=Math.floor(Math.random()*99)+2
}
var check=Math.floor(Math.random()*99)+2
So how do I check whether check
is a value of any of the a[j]
(that is a[0]
to a[10]
)? A good and simple method?
Try this:
a.indexOf(check) > -1