Javascript Scope Variable Inside A Variable Resistor