chaesthetics / FrontEnd-Dev

For Meta Certification
0 stars 0 forks source link

Ternary expressions in JSX #7

Open chaesthetics opened 1 year ago

chaesthetics commented 1 year ago
function Example() {
    return (
        <div className="heading">
            <h1>{Math.random() >= 0.5 ? "Over 0.5" : "Under 0.5"}</h1>
        </div>
    );
};

function Example3() {

    const getRandomNum = () => Math.floor(Math.random() * 10) + 1

    return (
        <div className="heading">
            <h1>Here's a random number from 0 to 10: { getRandomNum() }</h1>
        </div>
    );
};