random.js: Use typeof window to avoid ReferenceError on Node.

Node doesn't appear to let you reference undefined variables. Apparently you need to use typeof?