Tell us what’s happening:
these two tests are always wrong no matter what can someone please help cuz these two if statement are wrong no matter what i try(sorry for the bad english).
Describe your issue in detail here.
these are the two failed tests:
-
When the
#number
element contains the number-1
and the#convert-btn
element is clicked, the#output
element should contain the textPlease enter a number greater than or equal to 1
-
Failed:When the
#number
element contains the number4000
or greater and the#convert-btn
element is clicked, the#output
element should contain the textPlease enter a number less than or equal to 3999
.
Your code so far
<!-- file: index.html -->
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="./styles.css">
<title>Roman Numeral Conventer</title>
</head>
<body>
<h2>RNC</h2>
<h1>Enter a Number</h1>
<input id="number" class="ipt"></input>
<p>
<button id="convert-btn" class="btnn">Let's get a Number</button>
</p>
<div id="output" class="dvv"></div>
<script src="script.js"></script>
</body>
</html>
/* file: styles.css */
//* file: styles.css */
h3 {
text-align: center;
font-size: 35px;
color: #00FFFF;
}
body {
background-color: #2e2d2d;
}
h1, h2 {
text-align: center;
background-color: #4b586b;
border-radius: 17px;
color: #00BFFF;
}
.btnn {
font-weight: bold;
width: 160px;
height: 26px;
border-radius: 7px;
text-align: center;
color: #4169E1;
}
h2 {
color: #1E90FF;
}
.ipt {
font-weight: bold;
text-align: center;
color: #4169E1;
}
.dvv {
font-weight: bold;
text-align: center;
color: #DC123C;
background-color: #FF7F50;
border-radius: 9px;
}
/* file: script.js */
/* file: script.js */
document.getElementById("convert-btn").addEventListener("click", () => {
const input = document.getElementById("number")
const output = document.getElementById("output");
const num = parseInt(input.value, 10);
if(isNaN(num) || num <= 0 || num >= 4000) {
output.textContent = "Please enter a valid number";
} else {
output.textContent = convertToRoman(num)
}
function convertToRoman(num) {
const romanNumerals = [
["", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"],
["", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"],
["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"],
["", "M", "MM", "MMM"]
];
const thousands = Math.floor(num / 1000);
const hundreds = Math.floor((num % 1000) / 100);
const tens = Math.floor((num % 100) / 10);
const singles = num % 10;
return romanNumerals[3][thousands] + romanNumerals[2][hundreds] + romanNumerals[1][tens] + romanNumerals[0][singles];
}
})
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Challenge Information:
Build a Roman Numeral Converter Project - Build a Roman Numeral Converter