Currency Converter
Features:
Live Exchange Rates:
- Fetches real-time currency exchange rates using
https://api.exchangerate-api.com.
- Fetches real-time currency exchange rates using
Dropdowns for Currency Selection:
- Users can choose both source (
From Currency) and target (To Currency) currencies.
- Users can choose both source (
Dynamic Calculation:
- Converts the entered amount based on the selected currencies and displays the exchange rate and converted value.
Error Handling:
- Ensures the user enters a valid numeric value for the amount and handles invalid inputs gracefully.
Responsive Design:
- Works seamlessly across desktops, tablets, and mobile devices.
Colorful Styling:
- Vibrant gradient background and polished design for user engagement.
How It Works:
Initial Setup:
- On page load, the
populateCurrenciesfunction fetches the available currencies and populates the dropdown menus.
- On page load, the
User Interaction:
- Users select the currencies and enter the amount to be converted.
Conversion Logic:
- When the "Convert" button is clicked, the script:
- Fetches the exchange rate for the selected source currency.
- Calculates the converted amount using the formula:
- When the "Convert" button is clicked, the script:
Result Display:
- Shows the exchange rate and converted amount dynamically in the results section.
Error Handling:
- Displays a red error message if the input amount is invalid or missing.
No comments:
Post a Comment