Task: Replace Character with Function Node

n8n workflow JSON:
{"nodes":[{"name":"On clicking 'execute'","type":"n8n-nodes-base.manualTrigger","position":[500,440],"parameters":{},"typeVersion":1},{"name":"Set","type":"n8n-nodes-base.set","position":[660,440],"parameters":{"values":{"string":[{"name":"myText","value":"n8n is amazing"}]},"options":{}},"typeVersion":1},{"name":"Function","type":"n8n-nodes-base.function","position":[880,440],"parameters":{"functionCode":"// With this code, we are replacing the space with hypen in the given variable value\n\nconst search = ' ';\nconst replaceWith = '-';\n\nfor (item of items) {\n  item.json.myNewText = $node[\"Set\"].json[\"myText\"].split(search).join(replaceWith);;\n}\n\nreturn items;"},"typeVersion":1}],"connections":{"Set":{"main":[[{"node":"Function","type":"main","index":0}]]},"On clicking 'execute'":{"main":[[{"node":"Set","type":"main","index":0}]]}}}