Build a Roman Numeral Converter Project - Build a Roman Numeral Converter

Tell us what’s happening:

Can anyone describe why code is not passing test?

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SocialBook</title>
    <link href="styles.css" rel="stylesheet">
   
    
</head>
<body>
  <main>
    <input id="number"></input>
   <button onclick="noInput()" id="convert-btn">Convert</button>
   <div id="output"></div>
   
  </main>

   <script src="script.js"></script>
  </body>
  </html>
/* file: styles.css */

/* file: script.js */
document.getElementById("convert-btn").addEventListener("click",function(){
  const numberInput = parseInt(document.getElementById("number"));
  const output = document.getElementById("output");

if (isNaN(numberInput)) {
    output.textContent = "Please enter a valid number";
  } else if (numberInput <= 0) {
    output.textContent = "Please enter a number greater than or equal to 1";
  } else if (numberInput >= 4000) {
    output.textContent = "Please enter a number less than 4000";
  } else {
    output.textContent = convertToRoman(numberInput);
  }
  
  
  
});

function convertToRoman(num) {
  var romanNumerals = [
    { value: 1000, numeral: "M" },
    { value: 900, numeral: "CM" },
    { value: 500, numeral: "D" },
    { value: 400, numeral: "CD" },
    { value: 100, numeral: "C" },
    { value: 90, numeral: "XC" },
    { value: 50, numeral: "L" },
    { value: 40, numeral: "XL" },
    { value: 10, numeral: "X" },
    { value: 9, numeral: "IX" },
    { value: 5, numeral: "V" },
    { value: 4, numeral: "IV" },
    { value: 1, numeral: "I" }
  ];

  var roman = "";

  for (var i = 0; i < romanNumerals.length; i++) {
    while (num >= romanNumerals[i].value) {
      roman += romanNumerals[i].numeral;
      num -= romanNumerals[i].value;
    }
  }

  return roman;
}


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36

Challenge Information:

Build a Roman Numeral Converter Project - Build a Roman Numeral Converter

Hey, your noInput line in HTML isnt listed for addEventListener and its coming back as
an uncaught error. Good luck
CodePen: Uncaught ReferenceError: noInput is not defined

const numberInput = parseInt(document.getElementById("number"));

document.getElementById("number") is an element, not a value. You can not use parseInt with an element.

output.textContent = "Please enter a number less than 4000";

That is not the required text

When the #number element contains the number 4000 or greater and the #convert-btn element is clicked, the #output element should contain the text "Please enter a number less than or equal to 3999" .