Short-circuit OR in JavaScript
Level 267 keystrokes
The || operator returns the first truthy value or the last value if all are falsy.
JavaScript code
// Create an empty string (falsy value)1let input = "";// Use || to provide a default value// Since "" is falsy, "default" is returned2let value = input || "default";// Print the result3console.log(value);Output
default
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;× 3=× 2|× 2.× 1(× 1)× 1