function solution(arr, k) {
let answer = new Set();
arr.forEach(num => answer.add(num));
answer = [...answer].slice(0, k);
if (answer.length < k) {
let rest = Array((k - answer.length)).fill(-1);
answer = [...answer, ...rest]
}
return answer;
}
function solution (arr, k) {
return [...new Set(arr), ...Array(k).fill(-1)].slice(0, k);
}
function solution(arr, k) {
const set = new Set(arr);
return set.size < k ? [...set, ...Array(k - set.size).fill(-1)] : [...set].slice(0, k);
}
function solution(arr, k) {
return [...Array.from(new Set(arr)), ...new Array(k).fill(-1)].slice(0,k);
}
onst solution = (arr, k) => {
const set = new Set(arr);
const result = [...set].slice(0,k);
while(result.length !== k){
result.push(-1);
}
return result;
}