javascript - Function to scan list of arrays for a character and return all arrays that contain it -


i trying create function scan arrays character , return arrays contain character. example, how check if first string in array ends "_"?

example: searchnames([ [ "marco", "marco@polo.com" ], [ "john_", "john@doe.com" ] ]);  //should output [ [ "john_", "john@doe.com" ] ] 

this i've done far: http://jsfiddle.net/marcusdei/ve57p28h/

for prefer see code here:

function searchnames(logins){  var str = "_";  (var = 0; != logins.length; i++) {      var substring = logins[i];      if (str.indexof(substring) != - 1) {          return substring;         }     }         return null;  } 

applying javascript filter job :

[ [ "marco", "marco@polo.com" ], [ "john_", "john@doe.com" ] ].filter(     function(data){      return data[0]?data[0].lastindexof('_')==data[0].length-1:false; }); 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -