Sha256: 7023243926d76ab78e6e9b5fb8e47408b0fe52e80822a0a21f7b01159acb74ce
Contents?: true
Size: 746 Bytes
Versions: 73
Compression:
Stored size: 746 Bytes
Contents
'use strict'; module.exports = function (number) { var result = ''; var numbers = number; var mappings = [ {arabic: 1000, roman: 'M'}, {arabic: 900, roman: 'CM'}, {arabic: 500, roman: 'D'}, {arabic: 400, roman: 'CD'}, {arabic: 100, roman: 'C'}, {arabic: 90, roman: 'XC'}, {arabic: 50, roman: 'L'}, {arabic: 40, roman: 'XL'}, {arabic: 10, roman: 'X'}, {arabic: 9, roman: 'IX'}, {arabic: 5, roman: 'V'}, {arabic: 4, roman: 'IV'}, {arabic: 1, roman: 'I'} ]; for (var i = 0; i < mappings.length; i++) { var mapping = mappings[i]; while (numbers >= mapping.arabic) { result = result + mapping.roman; numbers = numbers - mapping.arabic; } } return result; };
Version data entries
73 entries across 73 versions & 1 rubygems