Skip to content

Added new function of currency converter#169

Open
adityakankal2004 wants to merge 1 commit intoDhanushNehru:mainfrom
adityakankal2004:function
Open

Added new function of currency converter#169
adityakankal2004 wants to merge 1 commit intoDhanushNehru:mainfrom
adityakankal2004:function

Conversation

@adityakankal2004
Copy link
Copy Markdown

Currency convert with your stylish calculator looks good.

Signed-off-by: aditya kankal <adityabuisness12@gmail.com>
@netlify
Copy link
Copy Markdown

netlify bot commented Aug 11, 2025

Deploy Preview for calculator-dhanushnehru ready!

Name Link
🔨 Latest commit 68392c1
🔍 Latest deploy log https://app.netlify.com/projects/calculator-dhanushnehru/deploys/689a355d03c663000839cc10
😎 Deploy Preview https://deploy-preview-169--calculator-dhanushnehru.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@adityakankal2004
Copy link
Copy Markdown
Author

Hey should i modify my changes

@DhanushNehru DhanushNehru requested a review from Copilot August 17, 2025 07:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a currency converter feature to an existing calculator application, providing users with the ability to convert between different currencies alongside the existing calculator functionality.

  • Adds a new currency converter component with support for 7 major currencies (USD, INR, EUR, GBP, JPY, AUD, CAD)
  • Implements conversion logic using hardcoded exchange rates with USD as the base currency
  • Integrates the converter into the existing UI with responsive styling that matches the application's design

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
style.css Adds comprehensive styling for the currency converter component including responsive design for mobile devices
script.js Implements the convertCurrency() function with hardcoded exchange rates and validation logic
index.html Integrates the currency converter UI elements into the existing calculator interface
Comments suppressed due to low confidence (1)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Comment thread script.js
}



Copy link

Copilot AI Aug 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded exchange rates will become outdated quickly and provide inaccurate conversions. Consider using a live exchange rate API or at minimum add comments indicating when these rates were last updated.

Suggested change
async function convertCurrency() {
const amount = parseFloat(document.getElementById("amount").value);
const fromCurrency = document.getElementById("fromCurrency").value;
const toCurrency = document.getElementById("toCurrency").value;
const resultElement = document.getElementById("convertedAmount");
if (isNaN(amount) || amount <= 0) {
alert("Please enter a valid amount.");
return;
}
try {
// Fetch live exchange rates from exchangerate.host
const response = await fetch(`https://api.exchangerate.host/latest?base=${fromCurrency}&symbols=${toCurrency}`);
if (!response.ok) {
throw new Error("Failed to fetch exchange rates.");
}
const data = await response.json();
const rate = data.rates[toCurrency];
if (!rate) {
throw new Error("Invalid currency code.");
}
const convertedValue = amount * rate;
resultElement.textContent = `${convertedValue.toFixed(2)} ${toCurrency}`;
} catch (error) {
resultElement.textContent = "Error converting currency.";
console.error(error);
}
}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I'll modify it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants