Each user's information is separated by a comma, or a space, but some pieces of information can be blank. I'm looking for a solution to take the user information and create an object (key-value mapping). Here's my approach, but I can't get multiple objects.
function Person(name, email, age, occupation) {
this.name = name;
this.email = email;
this.age = age;
this.occupation = occupation;
}
let string = "Norbert,[email protected],51,Coder Noemi,,,Teacher Rachel,[email protected],,"
let stringArr = string.split(/[\s,]+/)
const personObj = new Person(...stringArr)
console.log(personObj)