Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

171
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda