Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 477 Bytes

08-forbidden-stuff.md

File metadata and controls

26 lines (19 loc) · 477 Bytes

Ternaries nesting

Nesting ternaries operations is forbidden

/**
 * 😍 Cool 😍
 */

const isActive = accountState === "active" ? true : false;

const isAdmin = isActive && grade === "admin" ? true : false;

const message = isErrorCodeValid(errorCode)
  ? getUserMessage(errorCode)
  : getDefaultUserMessage();
/**
 * 😱 Not cool 😱
 */

const isAdmin =
  accountState === "active" ? (grade === "admin" ? true : false) : false;