DEV Community 👩‍💻👨‍💻

Discussion on: How Do You Name Your Boolean Variables?

gsto profile image
Glenn Stovall • Edited on

I prefer the first example in both cases. Specificity depends on the context. Does the function care about the "store" or not? Could Godzilla exist somewhere else, heaven forbid?

My go-to is to default to writing booleans in a way that makes them read more sentence-like in context. For example:

if ( godzillaExists && mothraExists ) {
  doBattle(godzilla, mothra)