javascript - How can I find a string in a two dimensional array? -


i have array looks this.

var array[["a","b"],["c","d"],["e","f"]];          

i want able search through array string "d" , return corresponding value "c".

try:

function find_str(array){   for(var in array){     if(array[i][1] == 'd'){       return array[i][0];     }   } } 

edit:

function find_str(array){   for(var i=0;i<array.length;i++){     if(array[i][1] == 'd'){       return array[i][0];     }   } } 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -