Adding 0x00 to the string would fail the function. And probably any other non-printable character would too.
[{"id":"5f8f404c8f069d15","type":"inject","z":"d2d96229134f29f0","name":"","props":[{"p":"packet","v":"57 029","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":770,"y":140,"wires":[["543cf8fd9d4bf86e"]]},{"id":"98aa909eef4126e1","type":"debug","z":"d2d96229134f29f0","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1270,"y":140,"wires":[]},{"id":"70d5cc0991a558fa","type":"function","z":"d2d96229134f29f0","name":"","func":"function only_num(s) {\n for (const character of s) {\n if (isNaN(character)) {\n return false;\n }\n };\n return true;\n};\nvar space_removed = msg.packet.replace(\" \", '');\nreturn {\n \"packet\": msg.packet,\n \"space_removed\": space_removed,\n \"only_num(space_removed)\": only_num(space_removed),\n};\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1100,"y":140,"wires":[["98aa909eef4126e1"]]},{"id":"543cf8fd9d4bf86e","type":"function","z":"d2d96229134f29f0","name":"add 0x00","func":"msg.packet = msg.packet + String.fromCharCode(0);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":920,"y":140,"wires":[["70d5cc0991a558fa"]]},{"id":"18f2869a5b932066","type":"inject","z":"d2d96229134f29f0","name":"","props":[{"p":"packet","v":"57 029","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":770,"y":100,"wires":[["70d5cc0991a558fa"]]}]