From 41d40608a1b807d2597c348914b2a03dd3acad1e Mon Sep 17 00:00:00 2001 From: Haraman Johal Date: Thu, 1 Oct 2020 12:26:43 +0100 Subject: [PATCH] fix(learn): reword incorrect line reference (#39742) --- .../react/render-conditionally-from-props.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/curriculum/challenges/english/03-front-end-libraries/react/render-conditionally-from-props.md b/curriculum/challenges/english/03-front-end-libraries/react/render-conditionally-from-props.md index 3752fa87f9..18606223f0 100644 --- a/curriculum/challenges/english/03-front-end-libraries/react/render-conditionally-from-props.md +++ b/curriculum/challenges/english/03-front-end-libraries/react/render-conditionally-from-props.md @@ -16,7 +16,7 @@ In this challenge, you'll set up a child component to make rendering decisions b
The code editor has two components that are partially defined for you: a parent called GameOfChance, and a child called Results. They are used to create a simple game where the user presses a button to see if they win or lose. -First, you'll need a simple expression that randomly returns a different value every time it is run. You can use Math.random(). This method returns a value between 0 (inclusive) and 1 (exclusive) each time it is called. So for 50/50 odds, use Math.random() >= .5 in your expression. Statistically speaking, this expression will return true 50% of the time, and false the other 50%. On line 30, replace the comment with this expression to complete the variable declaration. +First, you'll need a simple expression that randomly returns a different value every time it is run. You can use Math.random(). This method returns a value between 0 (inclusive) and 1 (exclusive) each time it is called. So for 50/50 odds, use Math.random() >= .5 in your expression. Statistically speaking, this expression will return true 50% of the time, and false the other 50%. In the render method, replace null with the above expression to complete the variable declaration. Now you have an expression that you can use to make a randomized decision in the code. Next you need to implement this. Render the Results component as a child of GameOfChance, and pass in expression as a prop called fiftyFifty. In the Results component, write a ternary expression to render the h1 element with the text "You Win!" or "You Lose!" based on the fiftyFifty prop that's being passed in from GameOfChance. Finally, make sure the handleClick() method is correctly counting each turn so the user knows how many times they've played. This also serves to let the user know the component has actually updated in case they win or lose twice in a row.