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
Post a Comment