== Why is this an issue?

When a function is called, it executes its block of code and uses a ``++return++`` statement within the function to specify the value that the function will produce as its result. This returned value can then be used or assigned to a variable in the calling code.

If a function returns a value that is not used or assigned to a variable, it may indicate that the function is not being used correctly or that there is a mistake in the code. This can make the code harder to understand and maintain, and can also lead to errors if the return value is needed later in the code.

Ignoring the return value of a function can be a sign of poor coding practices. It can indicate that the developer did not fully understand the purpose of the function or did not take the time to properly integrate it into the code.

This rule triggers an issue only on a predefined list of methods from built-in objects (`String`, `Number`, `Date`, `Array`, `Math`, and `RegExp`) to prevent generating any false-positives.

[source,javascript,diff-id=1,diff-type=noncompliant]
----
'hello'.lastIndexOf('e'); // Noncompliant: The return value is lost
----

Ensure that the return value of the function is used by assigning the return value to a variable.

[source,javascript,diff-id=1,diff-type=compliant]
----
let lastIndex = 'hello'.lastIndexOf('e'); 
----

Or use the value directly as part of an expression.

[source,javascript,diff-id=1,diff-type=compliant]
----
console.log('hello'.lastIndexOf('e'));
----

== Resources
=== Documentation

* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String[``++String++``]
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number[``++Number++``]
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date[``++Date++``]
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array[``++Array++``]
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math[``++Math++``]
* MDN web docs - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp[``++RegExp++``]

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[]
