Array.fromintermediateconst set = new Set([1, 2, 2, 3, 3])
Array.from(set) // β [1, 2, 3]Use Array.from() to convert a Set into an array, removing duplicates in the process.
A Set only holds unique values. By converting an array to a Set and back with Array.from(), you can remove duplicates in one expression. Set is iterable, so Array.from() works directly on it.
Challenge: Implement removeDuplicates that removes duplicate numbers from an array.
removeDuplicates([1, 2, 2, 3, 3, 3]) // β [1, 2, 3]
removeDuplicates([]) // β []