const romanToArabic = string => {
return string.split('').reduce((prevVal, currValue, i, arr) => {
const [a, b, c] = [
digits[arr[i]],
digits[arr[i + 1]],
digits[arr[i + 2]]
];
return b > a ? prevVal - a : prevVal + a;
}, 0);
};
const getNums = string => {
return string.split(/[+*\/-]/g).map(num => num.trim);
};
const getNums = string => {
return string.split(/[+*\/-]/g).map(num => num.trim());
};
const nums = getNums(string);
// ...
nums = nums.map(num => romanToArabic(num));