function mergeArrays(arr1, arr2) {
let commonArray = arr1.concat(arr2);
let sortComArr = commonArray.sort((a, b) => a - b);
let result = sortComArr.filter((current, i) => {
return sortComArr.indexOf(current) === i;
})
return result
}
console.log(mergeArrays([1, 1, 3, 5, 7, 9], [10, 8, 6, 4, 2]))
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