I need to assign a variable name from a second variable, then alert the value of the first variable in JavaScript.
Below is an example of what I am trying to achieve.
window.foo=0;
window.bar="window.foo";
//want to set an alert for window.bar in a way that returns 0
alert(window.bar); //returns window.foo
alert(Number(window.bar)); //returns window.NaN
In the example above, I am looking to alert the value 0. How would that be accomplished? Thank you.