Roman Numeral Converter project not passing

Hello, I’ve completed the JavaScript Roman Numeral converter checker project, I’ve run all of the tests successfully and when I click the “Run the Tests” button the tests run without any error.

However the project doesn’t complete… I’ve made some changes to the code and it still doesn’t complete the project.

Is the problem in the code?


<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8">
    <link rel="stylesheet" href="./styles.css">
    <title>Roman numeral converter</title>
      <input id = "number" type = "number"/>
      <button id = "convert-btn">Convert</button>
      <div id = "output">
    <script src="./script.js"></script>


const inputValue = document.getElementById('number');
const checkButton = document.querySelector('#convert-btn');
const result = document.querySelector("#output");

// initialize button
checkButton.onclick = checkInput;

function checkInput(){
  if(inputValue.value === null || inputValue.value === undefined || inputValue.value.trim().length === 0){
    result.innerText = 'Please enter a valid number';
  } else if(inputValue.value <= 0){
    result.innerText = 'Please enter a number greater than or equal to 1';
  } else if(inputValue.value >= 4000) {
    result.innerText = 'Please enter a number less than or equal to 3999;'
      } else {

function romanize (num) {
    if (isNaN(num))
        return NaN;
    var digits = String(+num).split(""),
        key = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM",
        roman = "",
        i = 3;
    while (i--)
        roman = (key[+digits.pop() + (i * 10)] || "") + roman;
    result.innerText = Array(+digits.join("") + 1).join("M") + roman;

I also tried the following function:

function romanize(num) {
  var lookup = {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},roman = '',i;
  for ( i in lookup ) {
    while ( num >= lookup[i] ) {
      roman += i;
      num -= lookup[i];
  result.innerText = roman;

And it works but still doesn’t complete the exercise

I don’t understand, if it runs without error it should pass. What happens when you press Run the tests?

Nothing happens… it displays this on the console only

The same thing happened to me in the previous certification exercise, turned out to be because of a global variable of the value of the input field but in this code I’m not setting any variables like that

So one of the tests doesn’t pass, that is not

Let’s see…

make sure your output is exacly as requested, no extra punctuation

Ohhh I thought when it said “//tests completed” it meant it had passed :sweat_smile:

Solved it now it had a “;” on the error text

Thank you

no, that means that all the tests have executed, not that they pass successfully