// app.js
Array.prototype.unique = function() {
let arr = [];
for(let i = 0; i < this.length; i++) {
if(!arr.includes(this[i])) {
arr.push(this[i]);
}
}
return arr;
}
const ages = [26, 27, 26, 26, 28, 28, 29, 29, 30]
const uniqueAges = ages.unique()
console.log(uniqueAges)
const arr = [1, 1, 1, 3, 2, 2, 8, 3, 4];
const uniqSort = (arr = []) => {
const map = {};
const res = [];
for (let i = 0; i < arr.length; i++) {
if (!map[arr[i]]) {
map[arr[i]] = true;
res.push(arr[i]);
};
};
return res.sort((a, b) => a − b);
};
console.log(uniqSort(arr));