I was initially making a number of bits (yes, a single 256-bit number, known in JavaScript as NaN), where the probability of a bit being set was based on a ratio, however "true randomness" could let the OP cheat so I had hacked a check loop on.
Yes, but that is not going to work because the OP can just keep generating until he gets one that favors him, and only THEN reveal it.
Please re-read my sentence. One sentence isn't too much to comprehend before posting. Finish reading until the end.
My second posted code only gives fair results. I added checking because I saw within minutes (not two months later) and addressed such a possibility for cheating:
I tweaked the code so only a secret grid with an equal number of 0 and 1 bits will be used (only about 1 in 20 will have an equal number). Otherwise the operator may search for one with bias.
The script also creates a unfalsifiable hash that can be published before gaming begins:
You post the SHA256 now so we can later verify the real secret "grid" was used.
The coding was just an example to show in comparison how preposterous, naive, and unprovable the original poster's game proposal was (bet against his unpublished Excel spreadsheet). Getting either a working Python environment or being able to do something with your JavaScript snippet are both tasks likely out of his depth.