| Level Navigation: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18⚡ | 19 |
User Story: As a player, I want the apple to disappear when I win so that I don’t accidentally keep clicking after winning.
Replace the conditional && with a ternary operator to show EITHER the apple OR the win message.
score < 100 ? ... : ...Need help with ternary operators? Check out these snippets:
<div className='orchard-background' onClick={missTarget}>
{ score < 100 ?
<div className="apple-target" onClick={clickTarget} style={appleStyle}></div>
: <h1 className="win"> You Win!</h1>
}
</div>
.win {
position: absolute;
background-color: green;
color: red;
left: 50%;
top: 50%;
translate: -50% -50%;
}
Ternary vs && operator:
&& operator: Shows component OR nothing? :: Shows component A OR component B