Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

167
Views
UMM so IV returns as invalid XLI also comes out invalid and also MDC and MCD returns as invalid, i think there are VERY minor things going on Help pls

if (skip) { skip = false;

}else {
  if (nextValue > romanValue) {

    if (romanValue == 5  romanValue == 50  romanValue == 500){ 
      return "Invalid"; 
    }
    arabicNumber = arabicNumber + nextValue - romanValue; 
    skip = true; 


var nextnextValue = dict[romanNumber[i+2]]; 

if (nextnextValue == romanValue)
  return "Invalid"; 

} else { arabicNumber = arabicNumber + romanValue;

} 

} UMM so IV returns as invalid XLI also comes out invalid and also MDC and MCD returns as invalid, i think there are VERY minor things going on function RomanToArabic(romanNumber){ var dict = { "I":1, "V":5, "X":10, "L":50, "C":100, "D":500, "M":1000 };

romanNumber = romanNumber.toUpperCase();

var romanValue = "";

var duplicateCheck = false;

var previousValue = 0;

var consecutiveNumbers = 0;

var skip = false;

var arabicNumber = 0;

for(var i = 0; i < romanNumber.length; i++) { romanValue = dict[romanNumber[i]];

if (romanValue == 5  romanValue == 50  romanValue == 500) {
  duplicateCheck = true; 

  if (duplicateCheck && romanValue == 5  romanValue == 50  romanValue == 500) {
    return "Invalid"; 
  }
} 

if (previousValue == romanValue) { consecutiveNumbers = consecutiveNumbers + 1;

  if (consecutiveNumbers >= 3 && (romanValue == 1  romanValue == 10   romanValue == 100   romanValue == 1000)) {
    return "Invalid"; 
  }
} 
else {
  consecutiveNumbers = 0; 
} 


var nextValue = dict[romanNumber[i+1]]; 


if (skip) {
  skip = false; 

}else {
  if (nextValue > romanValue) {

    if (romanValue == 5  romanValue == 50 || romanValue == 500){ 
      return "Invalid"; 
    }
    arabicNumber = arabicNumber + nextValue - romanValue; 
    skip = true; 


var nextnextValue = dict[romanNumber[i+2]]; 

if (nextnextValue == romanValue)
  return "Invalid"; 

} else { arabicNumber = arabicNumber + romanValue;

} 

}

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!