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

139
Vistas
Split paths and hashes into 2 different variables

I have one variable. The variable looks like this:

path1/path2,hash
path1/path2,hash
path1/path2,hash
path1/path2,hash

etc, etc.

How do I get 2 different variables, one containing the paths and the other containing the hashes?

For example, the paths will be like this:

path/path
path/path
path/path
path/path

I'm new to javascript btw, sorry.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

If I understand you correctly, you want to split all the content into two multi line string, then this peace of code could help to you.

let arrOfPathAndHash = `path1/path2,hash
path1/path2,hash
path1/path2,hash
path1/path2,hash`.split('\n');

arrOfPathAndHash = arrOfPathAndHash.map((pathAndHash) => pathAndHash.split(','));

const paths = arrOfPathAndHash.map((pathAndHash) => pathAndHash[0]).join('\n');
// path1/path2
// path1/path2
// path1/path2
// path1/path2

const hashes = arrOfPathAndHash.map((pathAndHash) => pathAndHash[1]).join('\n');
// hash
// hash
// hash
// hash
about 4 years ago · Santiago Trujillo 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