JSFiddle - React, Tailwind, and code Playground
by Sergey Linnick
JavaScript
const stringData = 'name\/surname\/birthday\/\/vasya\/petechkin\/23.12.12\/\/petya\/vasechkin\/23.12.12\/asdfasdfasdfasfas\/\/vasya\/petechkin';
const getResult = str => {
let array = str.split('\/\/'),
keys = array[0].split('\/'),
people = array.slice(1),
newArray = [];
people.forEach(person => {
let objVals = person.split('\/'),
obj = {};
keys.forEach((key, i) => {
obj[key] = objVals[i];
});
newArray.push(obj)
});
console.log(newArray)
}
getResult(stringData)