== Why is this an issue?

Unlike strongly typed languages, JavaScript does not enforce a return type on a function. This means that different paths through a function can return different types of values, which can be very confusing to the user and significantly harder to maintain.

In particular a function, in JavaScript, will return ``++undefined++`` in any of the following cases:

* It exits without a ``++return++`` statement.
* It executes a ``++return++`` with no value.

This rule verifies that return values are either always or never specified for each path through a function.


=== Noncompliant code example

[source,javascript]
----
function foo(a) { // Noncompliant, function exits without "return"
  if (a == 1) {
    return true;
  }
}
----


=== Compliant solution

[source,javascript]
----
function foo(a) {
  if (a == 1) {
    return true;
  }
  return false;
}
----


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

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

include::../message.adoc[]

include::../highlighting.adoc[]

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

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

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