# Why does this code not return the false

**URL:** <https://forum.freecodecamp.org/t/why-does-this-code-not-return-the-false/463083>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [June 2, 2021, 12:13pm UTC](https://forum.freecodecamp.org/t/why-does-this-code-not-return-the-false/463083 "2021-06-02T12:13:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![HollyBomb](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hollybomb/32/319898_2.png) [@HollyBomb](https://forum.freecodecamp.org/u/HollyBomb)\
**Post date:** [June 2, 2021, 12:13pm UTC](https://forum.freecodecamp.org/t/why-does-this-code-not-return-the-false/463083/1 "2021-06-02T12:13:13Z")

</div>

```auto
*/
function mutation(arr) {

  var a = arr[0].toLowerCase();

  var b = arr[1].toLowerCase().split("");

  var c = 0;

 for(var i = 0; i <= b.length; i++) {

   if(a.includes(b[i])){

     c++;

     return true;

   }

 } else return false;

}
*/

```

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [June 2, 2021, 2:04pm UTC](https://forum.freecodecamp.org/t/why-does-this-code-not-return-the-false/463083/2 "2021-06-02T14:04:15Z")

</div>

Hello there.

Do you have a question?

If so, please edit your post to include it in the **Tell us what’s happening** section.

Learning to describe problems is an important part of learning how to code.

Also, the more information you give us, the more likely we are to be able to help.

* * *

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (`</>`) to add backticks around text.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](https://forum.freecodecamp.org/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (’).

---

<div class="post-metadata">

**Author:** ![HollyBomb](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hollybomb/32/319898_2.png) [@HollyBomb](https://forum.freecodecamp.org/u/HollyBomb)\
**Post date:** [June 3, 2021, 11:03pm UTC](https://forum.freecodecamp.org/t/why-does-this-code-not-return-the-false/463083/4 "2021-06-03T23:03:52Z")

</div>

Hi randall,

Thank you for the feedback, i have altered the issue with the ‘else’ statement and moved it one line up. Also I have deleted the variable c as i can see that it has no purpose. The code now passes all of the tests except from the first one and i am perplexed as to why if all the others are working fine.

The new code reads:

```auto
function mutation(arr) {
  var a = arr[0].toLowerCase();
  var b = arr[1].toLowerCase().split("");

 for(var i = 0; i <= b.length; i++) {
   if(a.includes(b[i])){
     return true;
   } else return false;
 } 
}
  
mutation(["hello", "hey"]);

```

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [June 3, 2021, 11:42pm UTC](https://forum.freecodecamp.org/t/why-does-this-code-not-return-the-false/463083/5 "2021-06-03T23:42:03Z")

</div>

Try logging `a[i]` and `b[i]` inside the loop at the top.

> **Summary**
>
> ```auto
> function mutation(arr) {
> var a = arr[0].toLowerCase();
> var b = arr[1].toLowerCase().split("");
> 
> for(var i = 0; i <= b.length; i++) {
> console.log('a[i] ===', a[i])
> console.log('b[i] ===', b[i])
> if(a.includes(b[i])){
> return true;
> } else return false;
> } 
> }
> 
> mutation(["hello", "hey"]);
> 
> ```

* * *

Edit: Also, please include the link to the challenge when asking for help:

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/mutations)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [December 3, 2021, 11:42am UTC](https://forum.freecodecamp.org/t/why-does-this-code-not-return-the-false/463083/6 "2021-12-03T11:42:34Z")

</div>

Closed on December 3, 2021, 11:42am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
