I have an array of items arr = ['1a', '2b', '3c', '4d']
and some id id = 'sasaas'
. Now I want to make an array of objects such that elements of arr
would be properties on objects inside new array, like
[
{'id1' : id, 'id2': '1a'}
{'id1' : id, 'id2': '2b'}
{'id1' : id, 'id2': '3c'}
{'id1' : id, 'id2': '4c'}
]
I tried this
let arr = ['1a', '2b', '3c', '4d'];
let id = 'sasaas';
let c = arr.map(i => {'id1': id, 'id2': i})
but it didn't work. I don't what I'm doing wrong here, any Idea?