I need to compare two arrays & get the mismatched data from both into third array.
Details: following is the code I used for reference
var array1 = [1, 2, 3, 4, 8, 5, 6, 7];
var array2 = [6, 5, 4, 3, 2, 1] ;
var array3 = [];
for(var j=0; j<array1.length; j++)
{
var ar1 = array1[j];
//console.log("*****"+ar1+"*****")
for(var k=0; k<array2.length; k++)
{
var ar2 = array2[k];
//console.log("####"+ar2+"####")
if(ar1===ar2)
{
console.log(ar1+" is equal to "+ar2)
break;
}
// else
// if(k=array2.length)
// {
// console.log("the value "+ar1+" is not found")
// }
}
}
Please let me know if we can get mismatched data using this, else if you have any another way to compare & get mismatched data please provide the solution, Thanks !!!