// Example Arrays let filterArrayB = ['aa', 'ab', 'ac', 'ad', 'ae', 'af', 'ag'] let filterArrayA = ['aa', 'ab', 'ac', 'ae', 'af', 'ag'] // This only works if there is a 1 item difference compare = (a,b) => { let inBoth = [] let missingItem = [] a.forEach(item => { for (let i=0; i<b.length; i++){ if (item == b[i]){ inBoth.push(item) if (i == b.length) return } if (a.length < b.length) { b.forEach(item => { if (!a.includes(item)){ missingItem = item } }) } else { a.forEach(item => { if (!b.includes(item)){ missingItem = item } }) } } }) return missingItem } compare(filterArrayA, filterArrayB)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter