Tell us what’s happening:
My convertIntToRomanNum function call is not working as intended inside checkInput function. I tried to debug but unable to fix it. Please help me.
Your code so far
<!-- file: index.html -->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<input id="number" type="number"></input>
<button type="button" id="convert-btn">Convert</button>
<div id="output"></div>
</div>
<script src="script.js"></script>
</body>
</html>
/* file: script.js */
const input = document.getElementById("number");
const btn = document.getElementById("convert-btn");
const output = document.getElementById("output");
btn.addEventListener("click", () => {
checkInput();
input.value = "";
});
function checkInput() {
const userInput = input.value;
if(userInput === "") {
output.textContent = "Please enter a valid number";
return;
}
else if(userInput < 1) {
output.textContent = "Please enter a number greater than or equal to 1";
return;
}
else if(userInput > 3999) {
output.textContent = "Please enter a number less than or equal to 3999";
return;
}
else {
output.textContent = convertIntToRomanNum(userInput);
}
};
function convertIntToRomanNum(num) {
if(num === 1) {
return "I";
}
}
/* file: styles.css */
body {
background: linear-gradient(to right, lightblue, lightgreen);
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Challenge Information:
Build a Roman Numeral Converter Project - Build a Roman Numeral Converter