Checking whether certain item is in certain array using javascript -


i have 10 different arrays. each array has different numbers.

array1 = [1,2,3,4,5] array2 = [6,7,8,9,10] ... array 10 = [51,52,53,54]  

let's pass in 7. want know array , want return array number. in case going 2.

should write switch statement each array? appreciate in javascript.

try:

var arrays = [array1, array2, ..., array10];  for(var i=0; i<arrays.length; ++i) {    if (arrays[i].indexof(value) != -1) {        console.log('found in array' + (i+1));    } } 

Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -