Skip to content

Comment on How to win at rock-paper-scissorsparent

Comments

There is an equiprobability of winning/losing/draw. Your code is erroneous. You do a +1 to the random number you generate giving you 1, 2, 3. You then use that number to access an array with indexes [0, 1, 2]. You end with an undefined which screws your results.

Well if that was the case, then one result would always have 0. The indexes are used to find what something wins against

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.