Roman numeral conversion help

Right. But that is why you can’t see the overbar in the console. &#773 is an HTML character encoding.

If you need to print M̅ to the console you need something along the lines of 'M' + String.fromCharCode(773)

Note that in this example, I’m working from an HTML encoded string. If HTML is never a component of your converter, then that step is superfluous. I left that in because you asked about converting a string with the HTML encoding to an array.

1 Like

Ill just use that to get the arr ya of roman numerals, thanks :slight_smile:

Assuming the platform has full Unicode support, you can use alternative Roman numerals such as ↁ = 5000.

Thanks, we used a simple loop to get the actual line over top.

const charCodes = 'M&#773D&#773C&#773L&#773X&#773V&#773';
    const pattern = /.&#773/g;
    let charArray = charCodes.match(pattern);
    for (let i in charArray) {
        charArray[i] = charArray[i].replace(/&#773/g, String.fromCharCode(773));
    }

credit (ArielLeslie).

You can see the entire code at https://repl.it/@John_Nicole/Intermediate-Algorithm-Scripting-Roman-Numeral-Converter

(line 22 - 27 for the code just mentioned).