Skip to content

Instantly share code, notes, and snippets.

@uttamk
uttamk / bumpme
Last active March 5, 2019 09:03
Test gist
Tue Mar 5 09:03:23 UTC 2019
const romanToInt = function (s) {
let total = 0;
for (let i = 0; i < s.length;) {
let currentVal = valueMap[s[i]];
if (i === s.length - 1) {
total += currentVal;
break;
}
let nextVal = valueMap[s[i + 1]];
if (currentVal < nextVal) {
@uttamk
uttamk / intToRoman.js
Last active September 29, 2021 11:16
var intToRoman = function (num) {
let output = "";
const bases = [1000, 100, 10, 1];
for (let base of bases) {
const q = Math.floor(num / base);
const rem = num % base
if (q > 0) {
output += toFullBaseRoman(q, base);
}
num = rem;