Created
April 8, 2020 05:09
-
-
Save nicokosi/97d4843aeb9459340afb4c4bfd247e34 to your computer and use it in GitHub Desktop.
Roman numbers kata https://cyber-dojo.org/kata/edit/kAGG46
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
module.exports = { | |
roman | |
}; | |
function roman(arabic) { | |
let r = "I".repeat(arabic); | |
if (arabic === 4) { | |
return "IV"; | |
} | |
return r; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const roman = require('./roman.js'); | |
describe('Should convert roman', () => { | |
it('from 1', () => roman.roman(1).should.equal("I")); | |
it('from 2', () => roman.roman(2).should.equal("II")); | |
it('from 3', () => roman.roman(3).should.equal("III")); | |
it('from 4', () => roman.roman(4).should.equal("IV")); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment