Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
JavaScript is saying weird things like 14 + 2 = 116 or 11 + 9 = 93

my code is adding cMO1 = lTBC + keyCodeStr[lKIO]. it find lTBC and keyCodeStr right but when it adds them together weird things start to show up on the console. I started learning javascript 3 days ago and i am stuck.

console:

4 o 14
match
lTBC=14
keyCodeStr[lKIO]=2
conclusion2 = conclusion-25
keyCode= 48892
conclusion = 14 + 2=116

the code:

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 = []
var keyCodeStr;
////////////////////////////////////////////////////////////////////////////////////////////////    
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)

    if (lLIO == abc[lTBC]) {
      console.log("match")
      console.log("lTBC=" + lTBC)

      let keyCodeStr = keyCode.toString();

      console.log("keycodeStr[lKIO]=" + " " + keyCodeStr[lKIO])

      cMO1 = lTBC + keyCodeStr[lKIO]

      if (cMO1 > abc.length) {
        cMO1 = cMO1 - abc.length
        console.log("conclusion2 = conclusion-25")
      }
      
      console.log("keycode= " + keyCode)
      console.log("conclusion =" + " " + lTBC + " " + "+" + " " + keyCodeStr[lKIO] + "=" + cMO1)
      cypheredletter = abc[cMO1]
      cypheredmessage.push(cypheredletter, )
      console.log(cypheredmessage)
      lTBC = 0
      lKIO++
      lNIO++
      uMessageLength--

    } else {
      lTBC++
    }
  }
};
cypher(message)

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda