It rained today and sales was low.😢
I decided to use the opportunity to code. I created a simple bank account on the JS Codepad on my phone using enums, interfaces and functions.
These are the steps I took.
1) I made a list of transaction types either Deposit or Withdrawal using enum
2) I defined what a transaction would look like using interface.
3) I created the bank account with name, account number, starting balance, and an empty list of transactions using another interface.
4) I wrote 4 main functions:
a) deposit()
b) withdraw()
c) checkBalance()
d) viewHistory()
And finally tested it with a few deposits and withdrawals so when I run it, I instantly see the balance update and full transaction history.
You are welcome to Macazee Bank 🙏🤣
I built a mini shopping cart in TypeScript on my phone using JS Codepad by:
1)Making a list of categories (like Electronics, Grocery) using enum.
2)Defining what a product looks like (name, price, category, quantity) using interface.
3)Creating an empty cart as an array.
4)Writing 3 functions:
a)addToCart() → add or increase items
b)removeFromCart() → remove some or all
c)viewCart() → show cart with total price
Finally, testing it with a few products so it runs and shows output instantly.