I have an array with some values. How can I search that array using jquery for a value which is matched or close to it?
var a = [\"foo\",\"fool\",\"cool\",\"
try this:
var infoData = ["foo","fool","cool","god"],
search = 'oo';
//this makes the magic
infoData = $$(infoData).filter(function(){
return (this.search(search) >= 0)
})
var n = infoData.length;
console.log("size result: "+ n );
for(var item = 0; item < n ;item++){
console.log("item: "+item+" data : "+infoData[item]);
}
result:
size result: 3
item: 0 data : foo
item: 1 data : fool
item: 2 data : cool