Lesson 11: IF stament


I stuck at this lesson :

I think “x?y:z” or in lesson 12: “x&&y”, i think it similar to IF stament in someway.
but in early lesson say “if stament do not work in JSX”,
but “The Ternary Operator” is OK?
can anyone explain for me.

sorry for my poor english.


if statements and for loops are not expressions in JavaScript, so they can’t be used in JSX directly. Instead, you can put these in the surrounding code.

so we can’t use if and for inside a JSX directly (between the {}), however, a ternary operator is an expression so we can use it in JSX


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.