Created
March 31, 2024 01:20
-
-
Save tangentlin/cdb62b7c4c337ed517f85576096f3753 to your computer and use it in GitHub Desktop.
Imperative programming example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function processPayment(amount: number, method: string) { | |
switch (method) { | |
case 'credit': | |
// Process credit card payment | |
break; | |
case 'paypal': | |
// Process PayPal payment | |
break; | |
case 'bank_transfer': | |
// Process bank transfer | |
break; | |
// More payment methods... | |
default: | |
throw new Error('Unsupported payment method'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment