freeCodeCamp.org

My console keeps throwing me an error about semicolons but I think the code should work. Could someone help me?

Here’s my code

<html>
  <head>
    <meta charset="utf-8" />
    <link rel="stylesheet" href="styles.css" />
    <link rel="scriptsheet" href="./script.js" />
<title>Roman Numeral Converter</title>
  </head>
  <body>
<label for="number">Enter Numbers: </label>
<input id="number"></input>
<button id="convert-btn">convert</button>
<div id="output"></div>
<script src="./script.js"></script>
  </body>
</html>
<link rel="scriptsheet" href="./script.js" />
const number = document.getElementById("number");
const convertBtn = document.getElementById("convert-btn");
const output = document.getElementById("output");

const checkIfNumber = () => {
  if (number.length === 0;){
    output.textContent = "Please enter a valid number";
  } else if (number.value < 0;){
    output.textContent = "Please enter a number greater than or equal to 1";
  } else (number.value > 3999;){
    output.textContent = "Please enter a number less than or equal to 3999";
  }
}

function convertToRoman(num){

 checkIfNumber()

 const romanNumeral ="";

 const roman = {   
   numerals: [{
   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: 3, numeral: "III"},
   {value: 2, numeral: "II"},
   {value: 1, numeral: "I"}],
   values: [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 3, 2 ,1]
 };
 for (let i = 0; 
 i < roman.length; i++){while (num >= roman[i].value) {romanNumeral += roman[i].numeral; 
 num -= roman[i].value
 }
  return romanNumeral;
 }
}
convertBtn.addEventListener("click", convertToRoman);

What line is the error on?

the error is on line 10.

There we go, that’s a syntax bug. You shouldn’t have that semicolon there

it’s still throwing me an error.

you have the same issue on the other conditions, look at where the error is saying to look

and then the issue will be that else doesn’t take a condition

Look at that checkIfNumber() call. It is crying for a friendly semicolon companion.

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