console.log(result.toString().replaceAll(',', ' '));
const elementsCount = 10;
const firstArrayNum = [0, 0, 1, 1, 1, 2, 2, 3, 3, 4];
const main = (elementsCount, firstArrayNum) => {
const uniqueArray = [...new Set(firstArrayNum)];
const underscoreArr = new Array(elementsCount - uniqueArray.length).fill('_');
return [...uniqueArray, ...underscoreArr];
};
let result = main(elementsCount, firstArrayNum);
console.log(result);
console.log(result.toString().replaceAll(',', ' '));
Click Run to execute JavaScript.
Code runs in an isolated environment.
Code runs in an isolated environment.