# Roman Numerical Converter

## In this example below you will see how to do a Roman Numerical Converter with some HTML / CSS and Javascript

This awesome code was written by vhall_io, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
• HTML
• JavaScript
``````<!DOCTYPE html>
<html lang="en" >

<meta charset="UTF-8">
<title>Roman Numerical Converter</title>

<body>

<!--<div id="test"></div>-->

<script  src="js/index.js"></script>

</body>

</html>
``````
``````
function convertToRoman(num) {

var result = num;
var temp = 0;

//test if number is greater than or equal to 1000
if((result / 1000) >= 1){
temp = result;
//Returns how many times the number goes into 1000
temp = temp / 1000;
//rounds down to get a whole number
temp = Math.floor(temp);
//Adds that appropriate n quantities to the array
for(var i = 0; i < temp; i++){
}
//converts number in terms of 100 since there are not more
// 1000s left in it
result = result % 1000;
}
//This takes care of the special case
//Since you cannot have 4 C's, this handles all
//numbers between 900 to 10000
if((result < 1000) && (result >=900)){

result = result  - 900;
}

//test if number is greater than or equal to 500
if((result / 500) >= 1){
temp = 0;
temp = result;
//Returns how many times the number goes into 500
temp = temp / 500;
//Rounds down
temp = Math.floor(temp);

for(var o = 0; o < temp; o++){
}
//converts number in terms of 100 since there are not more
// 500s left in it
result = result % 500;
}

if((result / 100) >= 1){
temp = 0;
temp = result;
temp = temp / 100;
temp = Math.floor(temp);

for(var p = 0; p < temp; p++){
}

result = result % 100;
}

if((result < 100) && (result >= 90)){
result = result - 90;

}

if((result / 50) >= 1){
temp = 0;
temp = result;
temp = temp / 50;
temp = Math.floor(temp);

for(var a = 0; a < temp; a++){
}

result = result % 50;
}

if((result / 10) >= 1){

temp = 0;
temp = result;
temp = temp / 10;
temp = Math.floor(temp);

if(temp > 3){
}
if(temp <= 3){
for(var s = 0; s < temp; s++){
}
}

result = result % 10;

}

if(result == 9 ){
temp = 0;
result = result  % 9;
}

if((result / 5) >= 1){
temp = 0;
temp = result;
temp = temp / 5;
temp = Math.floor(temp);

for(var f = 0; f < temp; f++){
}

result = result % 5;
}

if((result / 1) >= 1){
temp = 0;
temp = result;
temp = temp / 1;
temp = Math.floor(temp);

if(temp > 3){
}

if(temp <= 3){
for(var g = 0; g < temp; g++){
}
}

result = result % 1;
}