javascript array find first element matching