Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!