Comparing Two String

hello im stuck maybe with basic problem (im beginner) comparing two string in debug node i see it well but i dont know why the comparation did not work (sorry for my englis Im salvadorean and english is not my native language)

[{"id":"a218cc37.9535","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"2c5a1218.c5de0e","type":"inject","z":"a218cc37.9535","name":"","topic":"","payload":"a","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":140,"wires":[["157174b5.e1ab0b","5a363900.519ba8"]]},{"id":"157174b5.e1ab0b","type":"function","z":"a218cc37.9535","name":"n","func":"var nombre1 = msg.payload;\n\nmsg.payload = {\n    \"content1\":nombre1\n    \n};\n\n\nreturn msg;","outputs":1,"noerr":0,"x":400,"y":70,"wires":[["56d31be7.f56de4","fa633bd3.3ae828"]]},{"id":"56d31be7.f56de4","type":"function","z":"a218cc37.9535","name":"Compara","func":"   \nvar n1 = String(msg.payload.content1);\nvar n2 = String(msg.payload.content2);\n\n\n\nif( n1.localeCompare(n2)=== 0){\n    \n     msg.payload = String(\"Iguales\");\n     return [msg,null];\n    \n}else{\n     msg.payload = String(\"NO\");\n    return [null,msg];\n}\n","outputs":2,"noerr":0,"x":620,"y":210,"wires":[["b73070d6.7f458"],["6e5abc60.3df234"]]},{"id":"fa633bd3.3ae828","type":"debug","z":"a218cc37.9535","name":"Received_String","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.content1","targetType":"msg","x":710,"y":140,"wires":[]},{"id":"b73070d6.7f458","type":"debug","z":"a218cc37.9535","name":"Funcion_OUT_OK","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":930,"y":210,"wires":[]},{"id":"5a363900.519ba8","type":"file in","z":"a218cc37.9535","name":"","filename":"input.txt","format":"utf8","chunk":false,"sendError":false,"encoding":"utf8","x":270,"y":280,"wires":[["a1be57a0.572518"]]},{"id":"6e5abc60.3df234","type":"debug","z":"a218cc37.9535","name":"Funcion_OUT_False","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":940,"y":280,"wires":[]},{"id":"a1be57a0.572518","type":"function","z":"a218cc37.9535","name":"n2","func":"var nombre2 = msg.payload;\nnombre2 = String(nombre2.trim('\\n'));\n\nmsg.payload = {\n    \"content2\":nombre2\n    \n};\n\n\n\nreturn msg;","outputs":1,"noerr":0,"x":400,"y":210,"wires":[["56d31be7.f56de4","5168ed4b.06a9b4"]]},{"id":"5168ed4b.06a9b4","type":"debug","z":"a218cc37.9535","name":"Received_String2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.content2","targetType":"msg","x":580,"y":280,"wires":[]}]

N2 received input from input.txt but N1 only receives a timestamp ?

The way you want to compare does not work like this. The "compara" node receive 1 message at a time, so it cannot compare. If you receive the same number of messages on both N1 and N2, you can use a batch + join node to make 1 message from both and compare those after they are combined.

Or perhaps look at node context to set a context to compare against.

no, de n1 received a string "a" in the file only have an "a" to.

but on the function if a put it only

var n1 = msg.payload.content1; // iqual to "a"
var n2 = msg.payload.content2; // iqual to "a"

you can use a batch + join node to make 1 message from both and compare those after they are combined.

OK thanks im going to try :smiley: