javascript - Compare two arrays and push different values to new array -


this question has answer here:

i have 2 arrays want compare , push values not same in both new array. i'm trying push values arraytwo not in arrayone new array.

  var arrayone = [[1,"121"], [2,"111"], [2,"321"], [3,"232"], [3,"213"], [4,"211"]],   arraytwo = [[4,"111"], [1,"131"], [3,"321"], [3,"232"], [3,"211"], [3,"213"], [1, "x1x"]];   donotmatch = [];  

i tried looping through first 2 arrays comparing values below isn't working:

 ( var = 0; < arrayone.length; i++ ) {         ( var e = 0; e < arraytwo.length; e++ ) {             if ( arrayone[i] !== arraytwo[e]) {                 donotmatch.push(arraytwo[e])                 }          }     } 

var arrayone = ["dog", "cat", "hamster", "gerbil", "turtle"],     arraytwo = ["hamster", "turtle", "gerbil"],     donotmatch = [];   for(var i=0;i<arrayone.length;i++){    if(arraytwo.indexof(arrayone[i])==-1){donotmatch.push(arrayone[i]);} }  //donotmatch ["dog","cat"] 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -