Alexandroppolus,
var arr = [1,1,2,5,9,9,7,7];
function unq(arr){
var newArr = [];
for(var i = 0; i<arr.length; i++){
var x = arr[i];
arr[i] = null;
if(!arr.includes(x)) {
newArr.push(x);
if(newArr.length == 2) return newArr;
continue;
}
arr[i] = x;
}
}
console.log(unq(arr));