I am attempting to take multiple (separate) arrays of strings and convert them into an array of objects with predefined keys. By predefined keys I mean Not using 0: "John", 1: "Doe"
etc…
How would I do this?
Multiple Arrays of strings
[
"John",
"Doe",
"123 Fake Street",
"Chicago",
"IL"
]
[
"Jane",
"Doe",
"456 Fake Street",
"Chicago",
"IL"
]
Desired result
// The keys are pre-set and won't change
// so this will be used as a template object to be populated with different values depending on the array of strings from above.
const myObject = {
first: '',
last: '',
street: '',
city: '',
state: ''
}
// I just want to fill the object with the array values above like so
const myObjects = [
{
first: 'John',
last: 'Doe',
street: '123 Fake Street',
city: 'Chicago',
state: 'IL'
},
{
first: 'Jane',
last: 'Doe',
street: '345 Fake Street',
city: 'Chicago',
state: 'IL'
}
]
There can be any number of arrays of strings.
Thank you.