I have two sets of arrays. I need to get the letters that are not in both arrays. First it should check if index 0 'a' is on both arrays. If it is in both than it should delete 'a' from both(just the first 'a' in first array not the one at the end(index 3). And go the the second item 'b' using same logic.
var arrayA = ['a','b','c','a'];
var arrayB = ['a','d','f','c'];
var arrayC = []; //Shoud have the result[b,a,d,f]
The code is set up at http://jsfiddle.net/rexonms/AbFYh/#base
HTML
<p class="arrayA">Array A</p>
<p class="arrayB">Array B</p>
<p class="arrayC">Array C</p>
jQuery
var arrayA = ['a','b','c','a'];
var arrayB = ['a','d','f','c'];
var arrayC = []; //Shoud have the result[b,a,d,f]
$('.arrayA').text('ArrayA: ' + arrayA);
$('.arrayB').text('ArrayB: ' + arrayB);
$.each(arrayA, function(indexA,valueA) {
$.each(arrayB, function(indexB, valueB){
if(valueA != valueB)
{
arrayC.splice(valueA);
}
});
$('.arrayC').text('ArrayC: ' + arrayC);
});