Tell us what’s happening:
I don’t understand what the issue is
The function is working great on close but when I click convert it doesn’t do anything
It asks for ‘output’ to have string element as the result when button is clicked so I added eventListener with String() so result can show like that
What am I doing wrong?
Your code so far
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
  <html>
    <head>
      <meta charset="UTF-8" />
      <meta name="viewport" content="widt=device-width initial-scale=1.0" />
      
      </head>
      <body>
        
        <input id="number"></input>
        <button id="convert-btn">Convert</button>
        <div id="output"></div>
        <script src="script.js"></script>
        </body>
    </html>
/* file: styles.css */
/* file: script.js */
const convertBtn = document.getElementById("convert-btn")
const numberInput = document.getElementById("number")
const output = document.getElementById("output")
convertBtn.addEventListener('click', () => {
  if(numberInput.value === "") {
    output.innerHTML = "Please enter a valid number"
  } else if (numberInput.value === "-1") {
    output.innerHTML = "Please enter a number greater than or equal to 1"
  } else if (numberInput.value >= "4000") {
    output.innerHTML = "Please enter a number less than or equal to 3999"
  }
});
function convertToRoman(num) {
  let romanNumeral = '';
  let romanList = [
    ["M", 1000], 
    ["CM", 900],
    ["D", 500],
    ["CD", 400],
    ["C", 100],
    ["XC", 90],
    ["L", 50],
    ["XL", 40],
    ["X", 10],
    ["IX", 9],
    ["V", 5],
    ["IV", 4],
    ["I", 1]
  ]
  for (let i = 0; i < romanList.length; i++) {
    while (num >= romanList[i][1]) {
      romanNumeral += romanList[i][0]
      num -= romanList[i][1]
    }
  }
  return romanNumeral
   
};
 convertBtn.addEventListener('click', () => {output.innerHTML = String(romanNumeral)}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3 Safari/605.1.15
Challenge Information:
Build a Roman Numeral Converter Project - Build a Roman Numeral Converter


