Loading

Quipoin Menu

Learn • Practice • Grow

react / Logical AND Operator in React
mcq
Direction: Choose the correct option

Q1.

What does the && operator do in JSX?
A. Returns the first falsy value or the last truthy value
B. Always returns a boolean
C. Renders nothing if left is falsy
D. Throws an error if left is falsy
Direction: Choose the correct option

Q2.

What will
{0 && Hi}
render?
A. <div><span>Hi</span></div>
B. <div>false</div>
C. <div>0</div>
D. <div></div>
Direction: Choose the correct option

Q3.

Why might you see '0' rendered unexpectedly when using &&?
A. Because 0 is falsy but React renders numeric 0
B. Because 0 is a valid React element
C. Because && returns 0
D. Because of a bug
Direction: Choose the correct option

Q4.

What is the result of {true &&

Hello

}?
A. Nothing
B. FALSE
C. <p>Hello</p>
D. TRUE
Direction: Choose the correct option

Q5.

Which is a safe way to conditionally render a component using &&?
A. {condition && 0 && <Component />}
B. {condition && <Component />}
C. Both A and C
D. {condition ? <Component /> : null}