[text] GITHUB ANS- swap num

Viewer

copydownloadembedprintName: GITHUB ANS- swap num
  1. {
  2.   "nodes": [
  3.     {
  4.       "id": "node1",
  5.       "type": "input",
  6.       "label": "Number 1",
  7.       "x": 100,
  8.       "y": 100
  9.     },
  10.     {
  11.       "id": "node2",
  12.       "type": "input",
  13.       "label": "Number 2",
  14.       "x": 100,
  15.       "y": 200
  16.     },
  17.     {
  18.       "id": "node3",
  19.       "type": "function",
  20.       "label": "Multiply",
  21.       "code": "const result = num1 * num2;\nreturn result;",
  22.       "x": 300,
  23.       "y": 150
  24.     },
  25.     {
  26.       "id": "node4",
  27.       "type": "function",
  28.       "label": "Swap",
  29.       "code": "const temp = num1;\nnum1 = num2;\nnum2 = temp;\nreturn [num1, num2];",
  30.       "x": 500,
  31.       "y": 150
  32.     },
  33.     {
  34.       "id": "node5",
  35.       "type": "output",
  36.       "label": "Debug",
  37.       "x": 700,
  38.       "y": 150
  39.     }
  40.   ],
  41.   "connections": [
  42.     {
  43.       "source": "node1",
  44.       "target": "node3",
  45.       "sourcePort": "value",
  46.       "targetPort": "num1"
  47.     },
  48.     {
  49.       "source": "node2",
  50.       "target": "node3",
  51.       "sourcePort": "value",
  52.       "targetPort": "num2"
  53.     },
  54.     {
  55.       "source": "node3",
  56.       "target": "node5",
  57.       "sourcePort": "result",
  58.       "targetPort": "value"
  59.     },
  60.     {
  61.       "source": "node1",
  62.       "target": "node4",
  63.       "sourcePort": "value",
  64.       "targetPort": "num1"
  65.     },
  66.     {
  67.       "source": "node2",
  68.       "target": "node4",
  69.       "sourcePort": "value",
  70.       "targetPort": "num2"
  71.     },
  72.     {
  73.       "source": "node4",
  74.       "target": "node5",
  75.       "sourcePort": "result",
  76.       "targetPort": "value"
  77.     }
  78.   ]
  79. }

Editor

You can edit this paste and save as new:


File Description
  • GITHUB ANS- swap num
  • Paste Code
  • 29 Apr-2024
  • 1.52 Kb
You can Share it: