Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. function convertToRoman(num) {
  2.  
  3. return ConvertValueToRoman();
  4. }
  5.  
  6. function ConvertValueToRoman(value, order)
  7. {
  8. var romanSet = ["I", "V", "X", "L", "C", "D", "M"];
  9. var tempSet = [];
  10. var result = "";
  11. if(order === 3) {
  12. tempSet.push(romanSet[6]);
  13. for (var i = 0; i < value; i++)
  14. result.push(tempSet[0]);
  15. } else {
  16. for (var i = 0; i < 3; i++)
  17. tempSet.push(romanSet[i + (order*2)]);
  18. switch (value) {
  19. case 0:
  20. result = "";
  21. break;
  22. case 1:
  23. case 2:
  24. case 3:
  25. for (var i = 0; i < value; i++)
  26. result.push(tempSet[0]);
  27. break;
  28. case 4:
  29. result.push(tempSet[0]);
  30. case 5:
  31. case 6:
  32. case 7:
  33. case 8:
  34. result.push(tempSet[1]);
  35. for (var i = 5; i < value; i++)
  36. result.push(tempSet[0]);
  37. break;
  38. case 9:
  39. result.push(tempSet[1]);
  40. result.push(tempSet[2]);
  41. break;
  42. }
  43. }
  44. return result;
  45. }
  46.  
  47. convertToRoman(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement