So I have this code, it loops through the this.product.taxons
and for each element, it looks through the array of objects this.taxons
to find the taxon
with the same value.
this.product.taxons.forEach((taxon) => {
// taxon = 'bed_sheet'
const data = this.taxons.find((x) => x.value === exclusion);
// data = {
// value: 'bed_sheet',
// model: 'bedSheet'
// }
this.currentProduct.`${data.model}` = true; // this does not work.
});
but my problem is that this.currentProduct.'${data.model}' = true;
which is translated to this.currentProduct.bedSheet = true;
and returns an error SyntaxError: Unexpected token
any other way to achieve this?