Tell us what’s happening:
Hey Guy,
Can someone please help me with a hint on my Project. I am done the HTML and CSS. Now I am working on the JavaScript function but, I need some help to complete my project (Roman Numeral Converter). The attached codes are what I setup but, they are not running.
Your help will highly be appreciated!
Your code so far
//Getting Elements from our html folder
const inputNumber = document.getElementById("number");
const convertBtn = document.getElementById("convert-btn");
const resultToOutput = document.getElementById("output");
//Establishing the numeral converter function
const romanNumeralConvert = () =>{
const arabic =getElementById("arabicnumeral").value;
const roman ="";
const arabicArr =[ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
const romanArr = [M, CM, D, CD, C, XC, L, XL, X, IX, V, IV, I];
if(/^(0|[1-9]\d*)$/.test(arabic)){
if(arabic = 0){
output.innerHTML = "Nulla";
}else if(arabic != 0){
for(let i = 0; i < arabicArr.length; i++){
while(arabicArr[i] <= arabic){
roman += romanArr[i];
arabic -= arabicArr[i];
}
}
}
}
};
// button function for discharging order
const convertBtn = (number) =>{
if(number.value === ""){
output.textContent("Please enter a valid number");
}else if(number.value === "-1"){
output.textContent("Please enter a number greater than or equal to 1")
}
};
convertBtn.addEventListener("click",convertBtn);
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