Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function convertToRoman(num) {
- return ConvertValueToRoman();
- }
- function ConvertValueToRoman(value, order)
- {
- var romanSet = ["I", "V", "X", "L", "C", "D", "M"];
- var tempSet = [];
- var result = "";
- if(order === 3) {
- tempSet.push(romanSet[6]);
- for (var i = 0; i < value; i++)
- result.push(tempSet[0]);
- } else {
- for (var i = 0; i < 3; i++)
- tempSet.push(romanSet[i + (order*2)]);
- switch (value) {
- case 0:
- result = "";
- break;
- case 1:
- case 2:
- case 3:
- for (var i = 0; i < value; i++)
- result.push(tempSet[0]);
- break;
- case 4:
- result.push(tempSet[0]);
- case 5:
- case 6:
- case 7:
- case 8:
- result.push(tempSet[1]);
- for (var i = 5; i < value; i++)
- result.push(tempSet[0]);
- break;
- case 9:
- result.push(tempSet[1]);
- result.push(tempSet[2]);
- break;
- }
- }
- return result;
- }
- convertToRoman(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement