include::../description.adoc[]

=== Exceptions

- the following numbers used in arithmetic operations: -1, 0, 1, as well as powers of 2 and 10
- time-related constants such as 24 and 60 are excluded
- numbers used in JSX elements are excluded
- enum values, default values, and other assignments are excluded
- arguments to `parseInt()` and `JSON.stringify()` are excluded
- numbers used in bitwise operations are excluded

include::../how-to-fix-it.adoc[]

=== Code examples

==== Noncompliant code example

[source,javascript,diff-id=1,diff-type=noncompliant]
----
function doSomething() {
  for (let i = 0; i < 4; i++) { // Noncompliant, 4 is a magic number
    // ...
  }
}
----

==== Compliant solution

[source,javascript,diff-id=1,diff-type=compliant]
----
function doSomething() {
  const numberOfCycles = 4;
  for (let i = 0; i < numberOfCycles; i++) { // Compliant
    // ...
  }
}
----



ifdef::env-github,rspecator-view[]

'''
== Implementation Specification
(visible only on this page)

include::../message.adoc[]

'''
== Comments And Links
(visible only on this page)

include::../comments-and-links.adoc[]

endif::env-github,rspecator-view[]
