Logical AND Operator in JavaScript

Level 270 keystrokes

Uses the && operator to check if both conditions are true.

JavaScript code

// Declare a variable with the boolean value true
1let a = true;
// Declare a variable with the boolean value false
2let b = false;
// && (AND) returns true only if BOTH values are true
// true && false = false (one is false)
3console.log(a && b);
// true && true = true (both are true)
4console.log(a && a);

Output

false
true
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this JavaScript code and how often they appear.

  • ;× 4
  • &× 4
  • .× 2
  • (× 2
  • )× 2
  • =× 2

More JavaScript examples at level 2

← JavaScript typing practice