# Something is wrong with "equal to" & "not equal to" if logic

**URL:** <https://community.n8n.io/t/something-is-wrong-with-equal-to-not-equal-to-if-logic/6786>\
**Category:** Questions\
**Created:** [16 Julio, 2021 22:25 UTC](https://community.n8n.io/t/something-is-wrong-with-equal-to-not-equal-to-if-logic/6786 "2021-07-16T22:25:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sovobih](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@sovobih](https://community.n8n.io/u/sovobih)\
**Post date:** [16 Julio, 2021 22:25 UTC](https://community.n8n.io/t/something-is-wrong-with-equal-to-not-equal-to-if-logic/6786/1 "2021-07-16T22:25:58Z")

</div>

I’ve seen this happening a lot of times but the if logic does not work correct a lot of times, I am really not sure how does the below data returns “true”

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/9/9c038f366f75ef51ae3a913e14ca407731c0daaa.png)

This should return the data for false instead of true or I am missing something?

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [17 Julio, 2021 08:24 UTC](https://community.n8n.io/t/something-is-wrong-with-equal-to-not-equal-to-if-logic/6786/2 "2021-07-17T08:24:45Z")

</div>

Welcome to the community @sovobih!

Honestly can not imagine that the IF-Node does not work correctly and never came across a case. After all, is the code very simple and it would mean that a lot of people would have broken workflows for a long time as there have been no changes to the IF-Node for a very long time. So that should have come up much earlier. We got a lot of reports like that in the past but it always turned out to be some misunderstanding. Just to be sure that this is not the case here, did I just test and all is working fine.

Incoming Data from a Function-Node:

 ![Screenshot from 2021-07-17 10-18-39](https://europe1.discourse-cdn.com/n8n/original/2X/9/90c3e9349144ebb124df383954804c7f9b4482c9.png)

And the `true` and `false` output of the IF-Node:

 ![Screenshot from 2021-07-17 10-19-11](https://europe1.discourse-cdn.com/n8n/original/2X/8/8ddba747a93ab3e0dad052f65140264f195a52c4.png)  
 ![Screenshot from 2021-07-17 10-19-19](https://europe1.discourse-cdn.com/n8n/original/2X/5/5b83cc292d65ed1cb9ae0f9863131ddfe7cc7a74.png)

Here also the workflow for you to test yourself:

So best to check if the value you have in “Value 1” is really `0` (so the number). Important to remember that ‘0’ is not ‘"0’" (so a string), also not `undefined` and also not `null`.

---

<div class="post-metadata">

**Author:** ![sovobih](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@sovobih](https://community.n8n.io/u/sovobih)\
**Post date:** [17 Julio, 2021 21:26 UTC](https://community.n8n.io/t/something-is-wrong-with-equal-to-not-equal-to-if-logic/6786/3 "2021-07-17T21:26:08Z")

</div>

Hi Jan,

Thanks for getting back. I totally understand that the code for if logic is pretty simple. I even tried the nodes you gave and these are returning proper results. One thing I would like to note is even if I try to run a test on my workflow it will return correct data most of the times, as of now this is only happening when a workflow is triggered using a webhook.

But I’ve definitely seen this not working in tests too in past as I totally remember setting up opposite option just because it was not giving the right output.

---

<div class="post-metadata">

**Author:** ![RicardoE105](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ricardoe105/32/550_2.png) [@RicardoE105](https://community.n8n.io/u/RicardoE105)\
**Post date:** [17 Julio, 2021 21:36 UTC](https://community.n8n.io/t/something-is-wrong-with-equal-to-not-equal-to-if-logic/6786/4 "2021-07-17T21:36:59Z")

</div>

Can you share your workflow? is it possible that expression is resolving to a value that is not a number.

---

<div class="post-metadata">

**Author:** ![Jorge\_M](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jorge_m/32/2336_2.png) [@Jorge\_M](https://community.n8n.io/u/Jorge_M)\
**Post date:** [18 Julio, 2021 08:41 UTC](https://community.n8n.io/t/something-is-wrong-with-equal-to-not-equal-to-if-logic/6786/5 "2021-07-18T08:41:21Z")

</div>

Hi,  
I have same, and that is my issue sometimes, it resolves to value (Although it seems number), when I switch to text it totally works fine.

---

<div class="post-metadata">

**Author:** ![jan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jan/32/9_2.png) [@jan](https://community.n8n.io/u/jan)\
**Post date:** [18 Julio, 2021 15:01 UTC](https://community.n8n.io/t/something-is-wrong-with-equal-to-not-equal-to-if-logic/6786/6 "2021-07-18T15:01:13Z")

</div>

As @Jorge_M mentioned is it a good idea to make sure that it is actually the expected type by converting the value to it.

If you want to be sure that it is a string you could do:

```javascript
={{ $json["number"].toString() }}

```

If you want to make sure it is a number:

```javascript
={{ parseFloat($json["number"]) }}

```
