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

224
Views
JavaScript: la variable está identificada pero un carácter especial de esa variable no está identificado

Tengo la variable "keycode" y puedo consolarla. Registrarla fuera de if{ } pero no dentro de ella. lo que mi código intenta hacer: produce un número de 5 dígitos llamado keyCode, luego toma la variable "mensaje", toma la primera letra, averigua qué orden tiene en el alfabeto y agrega el primer número del código clave y lo vuelve a convertir en una letra. y así sucesivamente (segunda letra del mensaje-segundo dígito del código clave)

el problema: console.log no dirá cuál es el primer o segundo dígito del código clave

lo que dice la consola:

 match keycode is69097 cMO1 is NaN 1stthingofkeycodeis unidentified

el código:

 getKeyCode() var keyCode; // the keycode used to cypher the message var message = "hello"; var uMessageLength; // the length of the uncyphered message var lNIO; // what number the variable "lLIO" has var lLIO; //the letter that is going to get cyphered var lTBC = 0 //which order of the letter in the alphabet the variable "lLIO" is going to get compared to var lKIO var cMO1 = 0 var cM = [] var abc = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", ]; var cypheredletter = " " var cypheredmessage = [] //////////////////////////////////////////////////////////////////////////////////////////////// function getKeyCode() { keyCode = Math.floor(Math.random() * 100000) console.log(keyCode) }; //////////////////////////////////////////////////////////////////////////////////////////////// function cypher(string) { uMessageLength = string.length lNIO = 0 lKIO = 0 while (uMessageLength > 0) { lLIO = message[lNIO] console.log(lNIO, lLIO, lTBC) console.log("keycode is" + keyCode) if (lLIO == abc[lTBC]) { console.log("match") console.log("1stthingofkeycodeis" + " " + keyCode[0]) console.log(keyCode) cMO1 = lTBC + keyCode[lKIO] console.log("cMO1 is" + " " + cMO1) if (cMO1 > abc.length) { cMO1 = cMO1 - abc.length } cypheredletter = abc[cMO1] cypheredmessage.push(cypheredletter, ) lTBC = 0 lKIO++ lNIO++ uMessageLength-- } else { lTBC++ } } }; cypher(message)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Está intentando obtener un valor indexado de un int. En su lugar, intente convertir el int en una cadena y luego obtenga el valor indexado. Aquí hay un fragmento de su código que ayuda a resolver su problema:

 if (lLIO == abc[lTBC]) { let keyCodeStr = keyCode.toString(); console.log("match") console.log("1stthingofkeycodeis" + " " + keyCodeStr[0]) cMO1 = lTBC + keyCodeStr[lKIO]

}

about 4 years ago · Juan Pablo Isaza Report
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!