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

119
Vistas
How to do string divided into letters then push into the next letter?
let output ="I am a string"

const app=output.split("")

console.log(app)

//output (13) [ "I", " ", "a", "m", " ", "a", " ", "s", "t", "r", "i", "n", "g" ]

then it need to change per letter into the next one in alphabetically

which means

"j","","b","n","","b,","","t","u","s","j","o","h"

after that the string must be written like ; "jbnbtusjoh"

any opinion?

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Ok, so lets do this step by step:

// first the string
let out = "I am a string"
// convert to array 
let arOut = out.split("") // gives ["I"," ", "a", "m", " ", "a"....]
// now lets get cracking : 

let mapped = arOut.map(element => element == ' ' ? element : String.fromCharCode(element.charCodeAt(0)+1))
// this get char code of element and then adds one and gets equivalent char ignores space

let newOut = mapped.join("") // we have our result

console.log(newOut)

about 4 years ago · Juan Pablo Isaza Denunciar

0

After splitting, map the array of characters, convert each one to code (if not a space), add one, and convert the code back to a char:

const output = 'I am a string'

const result = output.split('')
  .map(c => c === ' ' 
    ? c // ignore spaces
    : String.fromCharCode(c.charCodeAt(0) + 1) // convert char to code, add one, and convert back to char
  )
  .join('') // if you need a string

console.log(result)

You can also use Array.from() to directly convert the string to an array of the transformed characters:

const output = 'I am a string'

const result = Array.from(
  output,
  c => c === ' ' ? c : String.fromCharCode(c.charCodeAt(0) + 1)
).join('')

console.log(result)

about 4 years ago · Juan Pablo Isaza Denunciar

0

Why not convert each char into ASCII and then simply increment the number?

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