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

118
Vistas
Is there a way to know alle the positions of a certain part of a string?

I'm looking for a way to know all the positions of a certain part of a string, so for example, if I have a let variable = "test" and I want to know the location of all the "t"s.

I tried using indexOf(), but it does only return the location of the first "t" and stops afterwards.

Is there a way to do this with all "t"s?

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

0

let x = "test"
let y = []
for (let i = 0; i < x.length; i++){
   if (x[i] == "t") y.push(i)
}
console.log(y)

about 4 years ago · Juan Pablo Isaza Denunciar

0

let variable = "test";
for (let i = 0; i < variable.length; i++){
    if (variable[i] === 't'){
        console.log(i);
    }
}

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