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

226
Views
Estoy tratando de usar una declaración if para determinar si los números romanos son 4, 9, 40, 90, 400, 900 pero no estoy definido

No estoy definido cuando intento ejecutar mi código, no estoy seguro de por qué no activa la primera condición, ¿alguien sabe qué estoy haciendo mal? En este punto, sé que hay una mejor solución para resolver este problema, pero me gustaría saber qué estoy haciendo mal en este caso particular.

 var romanToInt = function(s) { let romanNumerals = {I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000} let integer = 0 let sToIndex = s.split("") for (let i = 0; i <= sToIndex.length; i++ ){ for (let j = 0; j <= romanNumerals.length -1; j++){ if (sToIndex[i] === "I" && (sToIndex[i + 1] === "V" || "X")){ integer = Object.values(romanNumerals)[j + 1] - 1 console.log(integer) } else if (Object.key(sToIndex)[i] === "X" & Object.key(sToIndex)[i + 1] === "C"|| "L"){ integer = Object.values(romanNumerals)[j + 1] - 10 return integer }else if (Object.key(sToIndex)[i] === "C" & Object.key(sToIndex)[i + 1] === "D" || "M"){ integer = Object.values(romanNumerals)[j + 1] - 10 return integer }else { integer = Object.values(romanNumerals)[j] + Object.values(romanNumerals)[j+1] return integer } } } } console.log(romanToInt("IV"))
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!