Array Value Equals String

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

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:

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

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