What is the most efficient method for transforming a scraped data array?
[ 'item 1', 'item 2', 'item 3', 'item 4'] [ '$99', '$99', '$99', '$99']
into object
{ name: 'item 1', price: '$100', }{ name: 'item 2', price: '$100', }{ name: 'item 3', price: '$100', }
I attempted
var keys = [
'name',
'price'
]
const mainData = {}
for (i = 0; i < 10; i++) {
let keyIdx = 0;
for (j = 0; j < 2; j++) {
if (l < 2) {
//bundle.name and bundle.price contains above mentioned array of name and price
mainData[keys[j]] = bundle.name[l];
// keyIdx++;
j++;
mainData[keys[j]] = bundle.price[l];
}
but it only outputs a single object { name: 'item 3', price: '$99' }