Question: How can I elegantly compare an array of strings to another array of strings thus returning an array of non-matching strings
var master = ['1','2','3','4']
var versioned = ['1a','2','3b','4']
var errorLog = []
var count = 0;
//this for loop doesn't work :(
for(var i = 0; i < versioned.length - 1; ++i ){
for(var j = 0; j < master.length -1; ++j){
if(versioned[i] === master[j]){
console.log('cleared');
}
if(count === master.length){
errorLog.push(versioned[i]);
}
}
}
loop will return ['1a', '3b'];
I feel like filter()
or map()
or reduce()
will do this but I'm unable to wrap my brain around this properly.