It's not clear what problem you're having, but the simplest way to remove duplicates in JavaScript is to use a
Set[
^]:
const removeDuplicates = nums => [...new Set(nums)];
However, the title and function name don't match your expected output, which clearly has duplicates in it. And since you haven't given us the input you use to produce that expected output, we can't even begin to guess what you're
actually trying to do.