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

257
Vistas
how to get first character of second string in javascript?

how to get first 2 character of string in javascript like this "Hello world " => get this "wo"? another example "Osama Mohamed" => M.

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

0

you can use string.split(' '), this function will split you string into an array, for example:

let s = "Hello World";
console.log(s.split(" ")) // will log ["Hello", "World"]

then you can get the second word using array[index] when index the index of your desired word in said array.

now using string charAt we can get the first letter of the word.

now to put everything together:

let s = "Hello World"
let s_splited = s.split(" ") // ["Hello", "World"]
let second_word = s_splited[1]
console.log(second_word.charAt(0))

about 4 years ago · Juan Pablo Isaza Denunciar

0

string = "Hello world";
split_string = string.split(" ");
second_word = split_string[1]
first_char = second_word[0]
console.log(first_char)

OR

string = "Hello world";
console.log(string.split(" ")[1][0])
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