Tell us what’s happening:
Describe your issue in detail here.
I don’t understand how this line of code checks a condition without any if/else syntax :
{this.state.display &&



  **Your code so far**

class MyComponent extends React.Component {
constructor(props) {
  this.state = {
    display: true
  this.toggleDisplay = this.toggleDisplay.bind(this);
toggleDisplay() {
  this.setState(state => ({
    display: !state.display
render() {
  return (
       <button onClick={this.toggleDisplay}>Toggle Display</button>
       {this.state.display &&  <h1>Displayed!</h1>}
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36

Challenge: Use && for a More Concise Conditional

Link to the challenge:

Hello there,

That is just what the && (and) operator does:

expr1 && expr2

" If expr1 can be converted to true , returns expr2 ; else, returns expr1 ."

I suggest you run this code in your favourite environment to experiment with the output:

const a = "I am truthy" && "So am I";
const b = null && "Do I show?"
const c = b || a; // Just for fun


Hope this helps

PS there are many different circuit operators

its a one line syntax, or even an inline syntax to do something, if something is true. It works similarly to the ternary operators-

condition ? is true : else  // if (condition) { true }; else ...

but there is no else transition, there is only an if

condition && is true  // if (condition) { true }

Thank You for your help

Thank you for your help

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