0

I want to search only the first column of myarray and return the index:

example search for "s1" returns 0, search "s3" returns 1, and so on

javascript

myarray = [
['s1', 's2'],
['s3', 's4'],
['s5', 's6']
]
1
  • 1
    We're are not going to just do this for you. Show us what, if anything, you attempted to do to solve this, and we will help you make it right. Commented Dec 14, 2012 at 16:43

1 Answer 1

1

thanks for all the help guys...

solution

function searchCPL(what, find){
  for(var i= 0, L= what.length; i<L; i++){
    if(what[i][0]=== find) return i;
  }
    return '';
};

searchCPL(myarray, 'value');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.