Write program to remove duplicates from an Array

// Function to remove duplicates from an array
function removeDuplicates(arr) {
  return Array.from(new Set(arr));
}

// Example usage
const withDuplicates = [1, 2, 2, 3, 4, 4, 5];
const withoutDuplicates = removeDuplicates(withDuplicates);
console.log(withoutDuplicates);

 

Post your Answer