function getNum(arr, a){
arr.sort();
for(let i = 0; i < arr.length; i++){
if(arr[i] > a){
if(i == 0) return `${arr[i]}`;
if( (arr[i] - a) > (arr[i-1] - a) ){
return `${arr[i-1]},${arr[i]}`;
} else {
return `${arr[i-1]},${arr[i-2]}`;
}
} else if (i == arr.length - 1){
return `${arr[i]}`;
}
}
}
let arr = [99,56,87,78,66,55];
console.log(getNum(arr, 88)); // 87,99
console.log(getNum(arr, 100)); // 99
console.log(getNum(arr, 10)); // 55