# Compare 2 strings

**URL:** <https://community.postman.com/t/compare-2-strings/42690>\
**Category:** Help Hub\
**Created:** [January 9, 2023, 9:29am UTC](https://community.postman.com/t/compare-2-strings/42690 "2023-01-09T09:29:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunilmuneppa-photon](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@sunilmuneppa-photon](https://community.postman.com/u/sunilmuneppa-photon)\
**Post date:** [January 9, 2023, 9:29am UTC](https://community.postman.com/t/compare-2-strings/42690/1 "2023-01-09T09:29:19Z")

</div>

I am comparing 2 strings. The first string, I get it from the excel sheet and the 2nd string I get it from the response.

Example: 1st String: “abc”  
2nd String from response: “abc xyz”

When I compare these 2 I should get an error as “abc” is not equal to “abc xyz”.  
But I see that I am not getting the error instead the test is getting passed.

**Below is the test function:**

const jsonData = pm.response.json();

var resName = jsonData.hits[0].Name;

var inputName = pm.iterationData.get(“name”);

pm.test(‘Name’, function(){  
pm.expect((inputName).toUpperCase).to.deep.eql((resName).toUpperCase)  
})

Here the resName is ‘abc xyz’ and inputName is ‘abc’. This should throw an error but the test is getting passed

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [January 9, 2023, 1:13pm UTC](https://community.postman.com/t/compare-2-strings/42690/2 "2023-01-09T13:13:10Z")

</div>

Postman uses CHAI for assertions.

[https://www.chaijs.com/api/bdd/](https://www.chaijs.com/api/bdd/)

_Causes all `.equal` , `.include` , `.members` , `.keys` , and `.property` assertions that follow in the chain to use deep equality instead of strict (`===` ) equality._

Just removed the deep from the assertion.

pm.expect((inputName).toUpperCase).to.eql((resName).toUpperCase)

---

<div class="post-metadata">

**Author:** ![sunilmuneppa-photon](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@sunilmuneppa-photon](https://community.postman.com/u/sunilmuneppa-photon)\
**Post date:** [January 9, 2023, 1:23pm UTC](https://community.postman.com/t/compare-2-strings/42690/3 "2023-01-09T13:23:38Z")

</div>

I tried to.eql as well. No change. Still the test passes which is invalid

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [January 9, 2023, 2:00pm UTC](https://community.postman.com/t/compare-2-strings/42690/4 "2023-01-09T14:00:20Z")

</div>

It should be the following.

```auto
pm.test("Name", function(){
    pm.expect(inputName.toUpperCase()).to.eql(resName.toUpperCase());
})`

```

![image](https://us1.discourse-cdn.com/getpostman/original/3X/7/7/77e668a7fd6f0b1866d2353f7fac7c1beb0d5139.png)

Because you aren’t calling the toUpperCase() function properly, the way you had it is basically comparing the text [Function: toUpperCase] for both variables. (Therefore passing each time).

---

<div class="post-metadata">

**Author:** ![sunilmuneppa-photon](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@sunilmuneppa-photon](https://community.postman.com/u/sunilmuneppa-photon)\
**Post date:** [January 9, 2023, 2:22pm UTC](https://community.postman.com/t/compare-2-strings/42690/5 "2023-01-09T14:22:32Z")

</div>

@michaelderekjones Thanks a lot. You made my day. Have a great year ahead
