I have an array, I need to return new array with the values in range (from a to b) BUT! I want to return without duplicates. I wrote the script below but it doesn't work properly.
let arr = [3, 9, 10, 23, 100, 100, 23, 4, 10, 13, 13];
let newArr = [];
let funcFilter = function(arr, a, b) {
for(let i = 0; i< arr.length; i++) {
if(arr[i] >= a && arr[i] <= b ) {
if(arr.indexOf(arr[i]) !== -1)
newArr.push(arr[i]);
}
}
return newArr;
}
console.log(funcFilter(arr, 3, 20))