I am trying to create dynamic variable, for example rather saying
let f0, f1 = '';
and then using these variable in forEach
{Object.keys(shop).forEach((element, key) => {
if (element == dName[0]) {
f0 = Object.values(shop)[key];
}
if (element == dName[1]) {
f1 = Object.values(shop)[key];
}
})}
trying below,
let k = 'f';
let i = 0;
for(i = 1; i < 2; i++) {
eval('let ' + k + i + '= \'\' ;');
}
console.log("f1=" + f1);
but console printing
f1=undefined
what wrong I am doing, thanks in advance
eval