I want the following function, when invoked to return an array of elements without duplicates
const removeDuplicates = nums => {
var result = Array.from(new Set(nums));
console.log(result)
}
removeDuplicates([1,1,2,2,3])
Basically, I want this function to work without console.log
but with invocation of it, like so removeDuplicates([1,1,2,2,3])
Please note that return is not working in this case as it stops the function from being invoked.
P.S. I have read a lot of answers related to my question, however they are not specifically answering my question; in particular, I want to invoke the removeDuplicates function with provided array of elements, like so: removeDuplicates([1,1,2,2,3]) and I expect it to return the elements without duplicates.
return Array.from(new Set(nums))not an option?