CodingNic

Build the Currency Converter

Add the Swap Workflow

Build the Currency Converter 20 min read

Add the Swap Workflow

Add the Swap Workflow

Add a swap handler that exchanges the page’s selected currencies.

javascript
function swap() {
  onPairChange(to, from);
}

Keep the existing button as the single action that triggers the change.

Test it

Select a non-default pair, click the swap button, and confirm Send and Receive exchange positions.

Checkpoint

The converter supports the full local pair-selection workflow: choose currencies or swap them.