Find string in array as value in mootools


/ Published in: JavaScript
Save to your folder(s)

You can find a string as an array row value.
Ex:
arr=['abcde','mdleo']
arr.find('dbd') -> array['abcde']
arr.find('akdowewo') -> array[] (empty)


Copy this code and paste it in your HTML
  1. // NEEDS MOOTOOLS 1.2 FRAMEWORK
  2.  
  3. Array.prototype.find = function(searchStr) {
  4. var returnArray = [];
  5. this.each(function(objeto,index){
  6. if (objeto.contains(searchStr)) {
  7. returnArray.push(objeto);
  8. alert('hay uno');
  9. }
  10. });
  11. return returnArray;
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.