# Array Value Equals String

**URL:** <https://discourse.nodered.org/t/array-value-equals-string/3451>\
**Category:** General\
**Created:** [25 September 2018 17:47 UTC](https://discourse.nodered.org/t/array-value-equals-string/3451 "2018-09-25T17:47:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryanjohnson00](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ryanjohnson00/32/2956_2.png) [@ryanjohnson00](https://discourse.nodered.org/u/ryanjohnson00)\
**Post date:** [25 September 2018 17:47 UTC](https://discourse.nodered.org/t/array-value-equals-string/3451/1 "2018-09-25T17:47:47Z")

</div>

I am trying to put an "if" in my code. My output[3] is debugging as a string and that is the value of the string. This if is not working to return my output[2]. Any suggestions?

var lines = msg.payload.split("~~");  
var output = [];  
output[0] = {payload:lines[0]};  
output[1] = {payload:lines[1]};  
output[2] = {payload:lines[2]};  
output[3] = {payload:lines[3]};  
if (output[3]=='ENABLED\_STATUS\_ENABLED') {  
return [output[2]];  
}  
return [output[1],output[3]];

Below is the debug showing the value of output[1] and output[3].  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/05a532700d92a68e9e090359f1ffc32dec5443ec.png)

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [25 September 2018 17:51 UTC](https://discourse.nodered.org/t/array-value-equals-string/3451/2 "2018-09-25T17:51:55Z")

</div>

If you look closely at the debug output, you'll see it is showing you the contents of `msg.payload`

`output[3]` is not a string - it's am object with a payload property. That's what you should be comparing with:

```auto
if (output[3].payload =='ENABLED_STATUS_ENABLED') {

```

---

<div class="post-metadata">

**Author:** ![ryanjohnson00](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ryanjohnson00/32/2956_2.png) [@ryanjohnson00](https://discourse.nodered.org/u/ryanjohnson00)\
**Post date:** [25 September 2018 17:57 UTC](https://discourse.nodered.org/t/array-value-equals-string/3451/3 "2018-09-25T17:57:01Z")

</div>

I love this Forum! 🙂 That was the issue. Thank you for pointing out the obvious, I am still learning this stuff and there is so much to learn.
