Max-Min-Identity
Documentation Index
Fetch the complete documentation index at: https://docs.sourcery.ai/llms.txt
Use this file to discover all available pages before exploring further.
Sourcery rule id: max-min-identity
Section titled “Sourcery rule id: max-min-identity”Description
Section titled “Description”Use max/min instead of if statement
Before
Section titled “Before”if (a < b) { c = a} else { c = b}c = Math.min(a, b)Explanation
Section titled “Explanation”We often need to work out the smallest or largest of two values, and the
most readable way to do this is to use the built-in min and max
functions. This results in a shorter and clearer way to achieve the same result.