The problem is not the distinction between local and non-local hidden variables, but the that the "value" in that code doesn't depend on the measurement being performed.
You can't understand anything about quantum mechanics without knowing that in order to measure a qubit (or anything, really) you need an observable, which is completely missing from that JS code (for a qubit, the observable for a simple projective measurement could be represented by a direction in space).
You can't understand anything about quantum mechanics without knowing that in order to measure a qubit (or anything, really) you need an observable, which is completely missing from that JS code (for a qubit, the observable for a simple projective measurement could be represented by a direction in space).