
Wondering if there is a better way of doing this? - ideqa
function myFunction() {
     &quot;use strict&quot;;
     var num = document.getElementById(&quot;numberToCalculate&quot;).value;
     document.getElementById(&quot;answer&quot;).innerHTML = &quot;&quot; + num + &quot; = &quot; +convert(num); 
}<p>function convert(n) {
        var romanN = &quot;&quot;;
        var hundreds = (n &#x2F; 100 | 0);
        var fifties = ((n % 100) &#x2F; 50 | 0);
        var tens = (((n % 100) % 50) &#x2F; 10 | 0);
        var fives = ((((n % 100) % 50) % 10) &#x2F; 5 | 0);
        var ones = (((n % 100) % 50) % 10) % 5;
        if (n &lt; 256) {
            for (var i = 0; i &lt; hundreds; i++) {
                romanN = romanN + &quot;C&quot;;
            }
            if (n % 100 &gt;= 90 &amp;&amp; fifties !== 0) {
                romanN = romanN + &quot;XC&quot;;
                fifties--;
                tens = tens - 4;
            }
            for (var i = 0; i &lt; fifties; i++) {
                romanN = romanN + &quot;L&quot;;
            }
            if (n % 50 &gt;= 40 &amp;&amp; tens !== 0) {
                romanN = romanN + &quot;XL&quot;;
                tens = tens - 4;
            }
            for (var i = 0; i &lt; tens; i++) {
                romanN = romanN + &quot;X&quot;;
            }
            if (ones % 4 === 0 &amp;&amp; fives % 2 === 1 &amp;&amp; ones !== 0 &amp;&amp; fives !== 0) {
                romanN = romanN + &quot;IX&quot;;
                fives = 0;
                ones = 0;
            }
            for (var i = 0; i &lt; fives; i++) {
                romanN = romanN + &quot;V&quot;;
            }
            if (ones % 4 === 0 &amp;&amp; ones !== 0) {
                &#x2F;&#x2F;if (fives % 2 === 0 &amp;&amp; fives !== 0) {
                    romanN = romanN + &quot;IV&quot;;
                &#x2F;&#x2F;}
            }
            else {
                for (var i = 0; i &lt; ones; i++) {
                    romanN = romanN + &quot;I&quot;;
                }
            }
        }
        else {
            romanN = &quot;NA&quot;;
        }
        return romanN;
}<p>this is the program working
http:&#x2F;&#x2F;ideqa.blogspot.com&#x2F;p&#x2F;numbers-to-roman-numeral-calculator.html
======
ideqa
this is js for quick reference

