Is it possible to create a variable using template strings? Here is a simple example of what I want to achieve:
let times, hours="fullTime";
if (hours === "fullTime") {
times = ["Day", "Night"];
} else {
times = ["Day"];
}
times.forEach((time) => {
const `${time}shift` = "8 hours";
}
console.log(DayShift);
log: "8 hours"
I want a new variable with a different name to be defined everytime that forEach loop iterates.
Thanks