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

Tell us what’s happening:

I don’t know how to make it convert. I guess math floor won’t help.

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
  <head>
<meta charset="UTF-8" />
    <meta name="viewport" content="width=500, initial-scale=1.0" />
<link  href="styles.css" rel="stylesheet" />
<title id="title">Roman Numeral Converter</title>
</head>
<body>
  <h1 id="h1">Roman Numeral Converter</h1>
<input id="number">
</input>
<button id="convert-btn">Convert</button>
<div id="output"></div>


<script src="script.js"></script>
</body>
  </html>
/* file: styles.css */
*, ::before, ::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  align-items: center;
}
#convert-btn {
  background: linear-gradient(#711DB0, #C21292, #EF4040, #FFA732)
}
body {
background: linear-gradient(#e66465, #9198e5);
}
#h1 {
  border-top: solid thick #9A1663;
  border-bottom: solid thick #E0144C;
  border-left: solid thick #FF5858;
  border-right: solid thick #FF97C1;
  margin-bottom: 10px;
 
}
div {
  margin-top: 10px;
  background: white;
  display: block;
  border-top: solid black;
  border-bottom: solid black;
  border-left: solid black;
  border-right: solid black;
  padding: 10px 50px 30px 0;
}
/* file: script.js */
const numberInput = document.getElementById("number");
const convert = document.getElementById("convert-btn");
const output = document.getElementById("output");
convert.addEventListener("click", () => {
  if (numberInput.value === "") {
    output.innerText = "Please enter a valid number"
  } else if (numberInput.value < 1) {
    output.innerText = "Please enter a number greater than or equal to 1"
  } else if (numberInput.value > 3999) {
    output.innerText = "Please enter a number less than or equal to 3999"
  }
}) 

Your browser information:

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

Challenge Information:

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

  • start by setting the type attribute of the input element to the value number, it’s by default a text type input, this means it can accept text input.
  • input element is a self-closing tag so you don’t need a closing tag remove it.

Math.floor can be useful, it depends on the algorithm you write

try to start with the steps as detailed as possible to go from a decimal number to a roman numeral, no code, only words

I think I have to store roman numerals and make a function that somehow converts Arabic numerals into Roman.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.