Skip to content

Instantly share code, notes, and snippets.

@bnse
Created October 7, 2022 17:14
Show Gist options
  • Select an option

  • Save bnse/631c070baee6d08bd75465e2fed0371d to your computer and use it in GitHub Desktop.

Select an option

Save bnse/631c070baee6d08bd75465e2fed0371d to your computer and use it in GitHub Desktop.
change array to array[object]
const people = [
'string 1',
'string 2',
'string 3',
'string 4',
'string 5',
'string 6',
]
let peopleObj = []
for (let index in people) {
let data = { key: index, data: people[index] }
peopleObj.push(data)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment