Roman numeral Converter

I am making the roman numeral Converter project, but I am stuck what should I do after this, so far I have taken the input from the DOM and made two arrays,

const numberInput = document.getElementById(“number”);
const output = document.getElementById(“output”)

const romanNumerals = [M, CM , D, CD, C, XC, L, XL, X, IX, V, IV, I];
const arabicNumbers = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];

also how can I improve my problem solving skills for future and build projects on my own. I know the concepts I dont know how to implement them or I get stuck

I have changed the arrays into an object

I have created the function
const toRomanNumber = () => {
if (parseInt(numberInput) === 1) {
output.textContent = “Please enter a number greater than 0”
}
};

What is the objective of this arrow function?

I have created this arrow function to call it when the user click convert? and if the number is less than 1 it is supposed to return that but it is not working

This is the modified code

const toRomanNumber = () => {
if (parseInt(numberInput) < 1) {
// output.textContent = “Please enter a number greater than or equal to 1”
console.log(“this is wrong!!!”)
}
};

What do you think this parseInt does?
Try to think about: what does parseInt expect as an input? Is numberInput the correct type of thing that parseInt is expecting?

ohhhh the numberInput is a reference to the DOM

1 Like

I did this and this is working now

const toRomanNumber = () => {
const inputVal = parseInt(numberInput.value);

if (inputVal < 1) {
// output.textContent = “Please enter a number greater than or equal to 1”
console.log(“this is wrong!!!”)
}
};

It seems you are now unstuck.
Always break up whatever problem you are working on into smaller pieces and try to solve them one at a time.

I passed the tests thanks a lot for guidance and helping. How should I approach making projects and is it fine if I am googling stuff when i am stuck,

Yes it is fine to Google.
You can also review other projects on fcc to help you gain insight into how they were solved.

Just break up the work into small problems and solve them one problem at a time.

1 Like