Converts an amount from one currency rate to another.
The amount to convert.
The exchange rate of the original currency (e.g., USD).
The exchange rate of the target currency (e.g., EUR).
The converted amount rounded to 2 decimal places.
// Convert $10 USD to EUR, where 1 USD = 1 and 1 EUR = 0.85const converted = convertCurrency(10, 1, 0.85);console.log(converted); // Output: 8.5 Copy
// Convert $10 USD to EUR, where 1 USD = 1 and 1 EUR = 0.85const converted = convertCurrency(10, 1, 0.85);console.log(converted); // Output: 8.5
// Convert 100 GBP to JPY, where 1 GBP = 1.2 and 1 JPY = 0.0075const yen = convertCurrency(100, 1.2, 0.0075);console.log(yen); // Output: 0.63 Copy
// Convert 100 GBP to JPY, where 1 GBP = 1.2 and 1 JPY = 0.0075const yen = convertCurrency(100, 1.2, 0.0075);console.log(yen); // Output: 0.63
Converts an amount from one currency rate to another.