In the randomGaussian() definition, the variable y2 is never declared. Is that an oversight? Or is it deliberate and I’m missing something. Thanks in advance.
y2 is declared on line 20.
EDIT (May 26, 2021):
Note that it is global, and therefore retains a value between function calls. It is initialized at a value of
Since it is global, and its value is changed on line 222, whenever
randomGaussian() executes, it maintains a state that enables that function to give us a different result each time it is called.
let y2 = 0;
Line 222 (inside the function):
y2 = x2 * w;
Thanks. I was focused on the inside of the function that I didn’t see it all the way at the beginning.