Skip to content

Instantly share code, notes, and snippets.

@kirkegaard
Created November 10, 2025 09:17
Show Gist options
  • Select an option

  • Save kirkegaard/a75edb94137c1d4b11a8e40d4736c101 to your computer and use it in GitHub Desktop.

Select an option

Save kirkegaard/a75edb94137c1d4b11a8e40d4736c101 to your computer and use it in GitHub Desktop.
let a = [1, 3, 5, 0, 0, 0];
let b = [2, 4, 6];
function merge(a, b) {
return [...new Set([...a, ...b])].filter(function (item) {
return item !== null && item !== undefined && item !== 0;
}).sort((a, b) => a - b);
}
const res = merge(a, b);
console.log(res);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment