I had got a question in my exam as follow:
we need to create function that will receive 1 array of all positive number and return all the duplicate values of the array in sorted order.
Here is the solution that I had implemented:
function solution(arr) {
return arr.filter((value,index)=>arr.indexOf(value)!==index).sort()
}
But the code was rejected. Can someone tell me what could be more optimized solution for this problem in Javascript?