It can be made easier to read:
const romanToArabic = (input) => [...input].reduceRight(( acc, letter, idx, arr, value = {m:1000, d:500, c:100, l:50, x:10, v:5, i:1}[letter.toLowerCase()], doubleSubtraction = letter == arr[idx + 1] // ignore IIX notation ) => { if (value < acc.high && !doubleSubtraction) { acc.Arabic -= value; } else { acc.high = value; acc.Arabic += value; } console.log(idx, letter, acc, 'value:', value, acc.high, arr[idx + 1]); return acc; }, { high: 0, Arabic: 0 }).Arabic; // return Arabic value
`
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It can be made easier to read:
`