JSFiddle - React, Tailwind, and code Playground
JavaScript
// declare some variable for use later.
let x = 5
let y = 4
// 1. the && pattern is use to execute a code if the condition pass.
true && console.log('code 1')
// the left side is the condition. the right side is the code.
//2. if the condition fail, then the code will not execute.
false && console.log('code 2')
//3. Let's use some useful example.
(x > 0) && console.log('code 3')
//4. The brackets in code 3 is for human to read easily. we can omit them
x > 0 && console.log('code 4')
//5. We can check multiple things.
(x > 0) && (y > 0) && console.log('code 5')
//6. if any of the check fail, then the code will not execute.
(x > 0) && (y >10) && console.log('code 6')