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

195
Views
Remove words from array of string

I have an array of strings:

[
  'Alica Brereton,Marijuana,9.18,50',
  'David Ernest,Methamphetamine,108.78,5',
  'David Ernest,cocaine,80,2',
  'Gabriella Hyde,Marijuana,9.18,10',
  'Gabriella Hyde,Methamphetamine,108.78,8',
  'Joel Forro,ecstasy,19.12,10',
  'Joel Forro,heroin,91.16,5',
  'William Kotai,ecstasy,19.12,20'
]

and i would like to remove the names from the start of each string so the end result would be:

[ 'Marijuana,9.18,50', 'Methamphetamine,108.78,5', 'cocaine,80,2', 'Marijuana,9.18,10', 'Methamphetamine,108.78,8', '19.12,10', 'heroin,91.16,5', 'ecstasy,19.12,20' ]

this is my existing code:

const fs = require("fs");
const data = fs.readFileSync("data.txt").toString();
const lines = data.split("\n");

let customerKeys = lines[0].replace("customer", "Total Price");
lines.shift();
console.log(customerKeys);
console.log(lines);

let array = lines.filter((str) => {
  return str !== "";
});
let arrNoSpaces = array;

arrNoSpaces.sort();
console.log(arrNoSpaces);

let keyValues = (customerKeys[0] += arrNoSpaces[1]);
keyValues += {};
console.log(keyValues);

customerKeys = customerKeys.split(",");
var TotalPrice = customerKeys.shift();
customerKeys.push(TotalPrice);


const customerNames = arrNoSpaces.map((line) => line.match(/\w+ \w+/)?.[0]);
about 4 years ago · Juan Pablo Isaza
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!