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

206
Views
Encuentra la palabra correcta incrementando letras en el alfabeto

Hola, encontré este desafío de la página jschallenger. Escribo el siguiente código y funciona bien a menos que se pase alguna letra mayúscula. Me parece que ltr = "abcdefghijklmnopqrstuvwxyz" no es la forma correcta. ¿Podría decirme cómo puedo mejorar mi código?

 function myf(a){ let ltr = "abcdefghijklmnopqrstuvwxyz" let newstr ="" for(i=0; i<=a.split("").length-1; i++){ let str = ltr.indexOf(a.charAt(i))+1 let mystr = ltr.charAt(str ) newstr += mystr } console.log(newstr) } myf("bnchm") // result: coding myf("bgddrd") // result: cheese myf("sdrshmf")// result:testing
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Puede calcular la letra analizando un carácter, obtener el valor en un sistema de 36 números y agregar uno. Para obtener el valor deseado sin acarreo, tome el resto de 36 y si es cero, agregue diez para obtener una 'a' (esto era una 'z' antes).

 function convert(string) { let result = ''; for (const c of string) { result += (((parseInt(c, 36) + 1) % 36) || 10).toString(36); } return result; } console.log(convert("bnchmf")); // coding console.log(convert("bgddrd")); // cheese console.log(convert("sdrshmf")); // testing console.log(convert("abcdefghijklmnopqrstuvwxyz")); // bcdefghijklmnopqrstuvwxyza

about 4 years ago · Juan Pablo Isaza Report

0

Espero que este código te ayude.

 const convert = (str) => { let result = ""; for (const char of str) { result += String.fromCharCode( char.charCodeAt(0) + 1 === 123 ? 97 : char.charCodeAt(0) + 1 === 91 ? 65 : char.charCodeAt(0) + 1 ); } console.log(result); }; convert("XYZ"); convert("bgddrz"); convert("bnchmf");

about 4 years ago · Juan Pablo Isaza Report

0

 // remember capitals var obj={}; for(let itr=0;itr<arg.toString().length;itr++){ if(arg[itr]==arg[itr].toUpperCase()){ obj[itr]=true // isUpperCase } // toLowerCase for(let iter=0;iter<String(arg).toLowerCase().split('');iter++){ // your code }

Las mayúsculas recordadas se utilizan para restaurar letras mayúsculas antes de registrar el resultado.

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!