Given a roman numeral, convert it to an integer.
Input is guaranteed to be within the range from 1 to 3999.
my solutions!
/**
* @param {string} s
* @return {number}
*/
var romanToInt = function(s) {
var map= {
i:1,
v:5,
x:10,
l:50,
c:100,
d:500,
m:1000
};
s = s.toLowerCase();
var t = 0;
for(var i = 0,l = s.length;i<l;i++){
t +=map[s.charAt(i)];
}
var t1 = s.match(/(iv|ix)/g);
var t2 = s.match(/(xl|xc)/g);
var t3 = s.match(/(cd|cm)/g);
t1 = !!t1?t1.length:0;
t2 = !!t2?t2.length:0;
t3 = !!t3?t3.length:0;
return t-2*t1-20*t2 -200*t3;
};