Skip to content

Utility class that will convert from int to roman numeral and vice versa

Notifications You must be signed in to change notification settings

pjpsoares/roman-numerals

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Roman Numerals

Utility class that will convert from int to roman numeral and vice versa

Setup

npm i

Unit tests

npm test

Linting

npm run lint

Using RomanNumber class

Instance creation

It's encouraged to instantiate a new value by using the new constructor like demonstrated below:

var romanNumber1 = new RomanNumber(‘XX’);
var romanNumber2 = new RomanNumber(40);

console.log(romanNumber1.toInt()); // => 20
console.log(romanNumber1.toString()); // => ‘XX’

console.log(romanNumber2.toInt()); // => 40
console.log(romanNumber2.toString()); // => ‘XL’

Errors thrown

There are 3 custom errors thrown:

  • invalid range - tried to create a new instance with an invalid value. The value must be between 1 and 3999.
  • value required - a value needs to be passed when creating a new instance. null, undefined or '' are not valid values.
  • invalid value - there was an error trying to parse the roman literal. Please review it.

Project timestamps

Begin

Mon Sep 05 2016 19:06:19 GMT+0100 (WEST)

End

Mon Sep 05 2016 23:14:47 GMT+0100 (WEST)

About

Utility class that will convert from int to roman numeral and vice versa

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published