include::../why.adoc[]

include::../how.adoc[]

=== Code examples

==== Noncompliant code example

[source,javascript,diff-id=1,diff-type=noncompliant]
----
function seek(input) {
  let target = 32;  // Noncompliant
  for (const i of input) {
    if (i === target) {
      return true;
    }
  }
  return false;
}
----

==== Compliant solution

[source,javascript,diff-id=1,diff-type=compliant]
----
function seek(input) {
  const target = 32;
  for (const i of input) {
    if (i === target) {
      return true;
    }
  }
  return false;
}
----

[source,javascript,diff-id=2,diff-type=noncompliant]
----

function getUrl(protocol, domain, path) {    
  let url; // Noncompliant
  url = `${protocol}/${domain}/${path}`;
  return url; 
}
----

==== Compliant solution

[source,javascript,diff-id=2,diff-type=compliant]
----
function getUrl(protocol, domain, path) {  
  const url = `${protocol}/${domain}/${path}`;
  return url;
}
----

== Resources

=== Documentation

* MDN - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const[const]

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

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

=== Message

Make "xxx" "const".


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