const number = document.getElementById("number");
const convertBtn = document.getElemenntById("convert-btn");
const output = document.getElementById("output");
const convertToRomanNumeral = () => {
if (number.value === "") {
output.innerHTML = "Please enter a valid number";
return String(output);
}
if (number.value < 1) {
output.innerHTML = "Please enter a number greater than or equal to 1";
return String(output);
}
if (number.value > 3999) {
output.innerHTML = "Please enter a number less than or equal to 3999";
}
}
convertBtn.addEventListener("click", () => {
convertToRomanNumeral(Number(number.value));
});

I’d like to know where I’m going wrong, because it seems like nothing shows up at the beginning.

const number = document.getElementById("number");
const convertBtn = document.getElementById("convert-btn");
const output = document.getElementById("output");
const convertToRomanNumeral = () => {
if (number.value === "") {
output.innerHTML = "Please enter a valid number";
return String(output);
}
if (number.value < 1) {
output.innerHTML = "Please enter a number greater than or equal to 1";
return String(output);
}
if (number.value > 3999) {
output.innerHTML = "Please enter a number less than or equal to 3999";
}
const romanNumerals = {
1: "I",
4: "IV",
5: "V",
9: "IX",
10: "X",
16: "XVI",
649: "DCXLIX",
1023: "MXXIII",
3999: "MMMCMXCIX"
}
let result = "";
for (let value in romanNumerals) {
while (number.value >= value) {
result += romanNumerals[value];
number.value -= value;
}
}
return result;
}
convertBtn.addEventListener("click", () => {
convertToRomanNumeral(Number(number.value));
});

Even based on the link you gave me, I went through it and somewhat got the algorithm. The link says to continue until you reach zero. But the actual Roman numeral doesn’t come.

for (let value in romanNumerals) {
while (number.value >= value) {
result += romanNumerals[value];
number.value -= value;
}
result = output.value;
}
return result;