scrimba
Frontend Career Path
React basics
Meme generator
Conditional rendering: ternary
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Conditional rendering: ternary
AboutCommentsNotes
Conditional rendering: ternary
Expand for more info
Joke.js
run
preview
console
import React from "react"

export default function Joke(props) {
const [isShown, setIsShown] = React.useState(false)
function toggleShown(){
setIsShown(prevShown => !prevShown)
}
return (
<div>
{props.setup && <h3>{props.setup}</h3>}
{isShown && <p>{props.punchline}</p>}
<button onClick={toggleShown}>Show Punchline</button>
<hr />
</div>
)
}
Console
/index.html
-2:49