JavaScript comparing and filtering arrays -



JavaScript comparing and filtering arrays -

my code gets matches in array2. need array1's matches

so array1 trying numbers match, i.e. 61, 35, 100.

is possible without major rewrites?

array1 = ["1x3","purple","100","yes","no","61","4/4/14","no","35","silver","yes"] array2 = ["id_2310", "35"] ["id_1223", "61"] ["id_8001", "100"] newarray = consolidatedfilters(array2, array1); function consolidatedfilters(passedarray, passedfilter) { var filteredarray = passedarray.filter( function(el) { (var = 0; < passedfilter.length; i++) { if (el[1].indexof(passedfilter[i]) != -1) { homecoming true; } } homecoming false; } ); homecoming filteredarray; }

on side note, comparing strings no-no? way have populate array1 .innerhtml it's string

add .map( function(item) { homecoming item[1] }) filter( )

javascript arrays

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -