diff --git a/PARTICIPANTS.md b/PARTICIPANTS.md index 5a2e2f4..2ea2a5b 100644 --- a/PARTICIPANTS.md +++ b/PARTICIPANTS.md @@ -142,3 +142,13 @@ - šŸ”­ Connect with me: **[Piyushjar](https://github.com/piyushjar))** --- +### Connect with me: + + + +- šŸ‘Øā€šŸ’» My name is **Sajib** +- šŸŒ± Iā€™m a MERN Stack Developer. +- šŸ“« Reach me: **contact2sajib@gmail.com** +- šŸ”­ Connect with me: **[19sajib](https://github.com/19sajib)** + +--- diff --git a/javascript/12-Integer-to-Roman.js b/javascript/12-Integer-to-Roman.js new file mode 100644 index 0000000..3c326f3 --- /dev/null +++ b/javascript/12-Integer-to-Roman.js @@ -0,0 +1,37 @@ +/** + * @param {number} num + * @return {string} + */ + var intToRoman = function(num) { + const romanValue = { + I: 1, + IV: 4, + V: 5, + IX: 9, + X: 10, + XL: 40, + L: 50, + XC: 90, + C: 100, + CD: 400, + D: 500, + CM: 900, + M: 1000, + }; + let result = ''; + + for (key in romanValue) { + const repeatCount = Math.floor(num / romanValue[key]); + + if (repeatCount !== 0) { + result += key.repeat(repeatCount); + } + + num %= romanValue[key]; + + if (num === 0) return result; + } + + return result; + +}; \ No newline at end of file