I have some collections of matching elements I am using to change an element’s class to a different class. However, I need to select the correct collection using the input to a function but when I give a variable to “Object.entries()”, it returns some other array. For example:
const classChanges_1 = { one: 'nine', two: 'eight', three: 'seven', ... };
/* works */
var pairs_1 = Object.entries(classChanges_1);
console.log(pairs_1);
/* doesn't work */
/* the "variable" variable is only here for the example but in my project it is input to a function */
var variable = "classChanges_1";
var pairs_2 = Object.entries(variable);
console.log(pairs_2);