Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

136
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda