diff --git a/curriculum/challenges/english/03-front-end-development-libraries/react/render-conditionally-from-props.md b/curriculum/challenges/english/03-front-end-development-libraries/react/render-conditionally-from-props.md index e69e98305a9..9c1a016d92b 100644 --- a/curriculum/challenges/english/03-front-end-development-libraries/react/render-conditionally-from-props.md +++ b/curriculum/challenges/english/03-front-end-development-libraries/react/render-conditionally-from-props.md @@ -123,7 +123,7 @@ Each time the button is clicked, the counter state should be incremented by a va })(); ``` -When the `GameOfChance` component is first mounted to the DOM and each time the button is clicked thereafter, a single `h1` element should be returned that randomly renders either `You Win!` or `You Lose!`. +When the `GameOfChance` component is first mounted to the DOM and each time the button is clicked thereafter, a single `h1` element should be returned that randomly renders either `You Win!` or `You Lose!`. Note: this can fail randomly. If that happens, please try again. ```js (() => { @@ -265,6 +265,11 @@ class GameOfChance extends React.Component { # --solutions-- ```jsx +// We want this to be deterministic for testing purposes. +const randomSequence = [true, false, false, true, true, false, false, true, true, false]; +let index = 0; +const fiftyFifty = () => randomSequence[index++ % randomSequence.length]; + class Results extends React.Component { constructor(props) { super(props); @@ -290,11 +295,10 @@ class GameOfChance extends React.Component { }); } render() { - const expression = Math.random() >= 0.5; return (
- +

{'Turn: ' + this.state.counter}

);