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

192
Views
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
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!