Вариант
nerv без for
alert(promptNumbers(3));
/**
* @param {Number} count
* @returns {Array<Number>}
*/
function promptNumbers(count) {
let arr = new Array(count),
i = 0;
while (i < count) {
n = Number(prompt('Enter a number'));
if (isNaN(n)) {
alert(`It is not a number!`);
continue;
}
if (contains(arr, n)) {
alert(`The number "${n}" already exists!`);
continue;
}
arr[i] = n;
i++;
}
return arr;
}
function contains(arr, needle) {
return arr.indexOf(needle) !== -1;
}