[{name: 'John', age: 21}, {name: 'Victor', age: 29}, ...]
name: 'John', age: 21, name: 'Victor', age: 29, ...
// formData это ваш объект для получения данных
const names = formData.getAll('name')
const ages = formData.getAll('age')
let result = []
for (let count = 0; count < names.length; count++) {
let user = {
name: names[count],
age: ages[count]
}
result.push(user)
}
return result //это и будет выходной массив
name: 'John', age: 21, name: 'Victor', age: 29, ...
data = "name: 'John', age: 21, name: 'Victor', age: 29, name: 'John2', age: 211, name: 'Victor2', age: 234"
arr = []
split = data.split(',')
for(let i = 0; i < split.length; i += 2) {
arr.push( [ split[i].split(':'), split[i + 1].split(':') ] )
}
arr.map(elem => Object.fromEntries(elem))