When picking a name for a boolean variable or a function that returns a boolean, be sure it’s clear what true and false really mean.
🚨 Problems
Your code has boolean variables that are named in a way that makes it difficult to understand what they mean.
const open = true;
const write = true;
const fruit = true;
✅ Solution
Booleans can hold only 2 values, true
or false
. Given this, using prefixes like is
, has
, can
, or should
can make booleans more clear.
const isOpen = true;
const canWrite = true;
const hasFruit = true;