I have an array that I would like to be able to search for certain strings.
Here is an example of the array output in the Debug window.
Then I would like to search for "NJ"
If NJ is found, then the output should say True or 1, else it should say 0 or false.
Thank you for the reply.
Sorry I'm new to this and still learning.
So here is my setup.
I have the API dumping out a json file and have it parsed into msg.payload.
Next I have the Switch configured to look at only the states which gets me the array output of
and that is dumping out to msg.cities.
In the function node, I have:
I am showing a WA in the msg.cities debug. But the function node is still outputting false, or in a normal debug block it shows Undefined.
very close , try:
const bool = msg.cities.includes("WA");
msg.payload = bool;
the include method doesn’t change the array but is a function that returns a boolean value. so you need to assign that returned value to a var.
Thanks Johannes! That worked!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.