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

224
Views
Lodash + Json: Split and display grouped data into a JSON file(Help)

I'm learning lodash functions and I've been trying to find a method to split a data set and group using lodash. Any immediate help would be highly appreciated.

The dataset is as follows

car:brand:ford,
car:brand:audi,
car:brand:volvo,
car:brand:toyota, lexus,

phone:brand:samsung,
phone:brand:apple, iPhone, xr,
phone:brand:huawei,
phone:brand:nokia, lumia,

And the expected out come with split and grouped is as follows

"car:brand": [ 

    "ford",,
    "audi",
    "volvo",
    "toyota, lexus",
],

"phone:brand": [ 

    "samsung",
    "apple, iPhone, xr",
    "huawei",
    "nokia, lumia",
],

So far I've come up with this part, and I'm stuck. I would like to learn how to do it using lodash _.split mainly

let brand = 'dataset'
let arr = _.chain(brand)
.split('car:brand:')
.join(',')
.split('phone:brand:')
.join(',')
.split(',')
.chunk(2)
.value();
console.log(arr);

This is not successful, is there an efficient way to split and group the data set using lodash functions? Any help would be much appreciated.

Console output

(8) [Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2), Array(2)]
0: (2) ["", "ford"]
1: (2) ["", "audi"]
2: (2) ["", "volvo"]
3: (2) ["", "toyota"]
4: (2) ["lexus", ""]
5: (2) ["samsung", ""]
6: (2) ["apple", " iPhone"]
7: (2) [" xr", ""]
length: 8

When expanded

0: Array(2)
0: ""
1: "ford"
length: 2
[[Prototype]]: Array(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!