generated from HackYourFuture/core-assignment-week-2
-
Notifications
You must be signed in to change notification settings - Fork 19
Shadi A. #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shmoonwalker
wants to merge
7
commits into
HackYourAssignment:main
Choose a base branch
from
shmoonwalker:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Shadi A. #26
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
777de70
implement detecting leap year logic with user input validation
shmoonwalker 5d456e1
implement login logic with credential validation and login page blocking
shmoonwalker bd0afab
fixed bugs in currency converter , display the current exchange rate
shmoonwalker fe32dc7
improve code readability for leap year
shmoonwalker 6c24205
Merge branch 'feature/add-leap-year-task-1'
shmoonwalker 8ae200f
Refactor leap year,fixed bugs and solved reviews
shmoonwalker d706739
Refactor login function for better error handling
shmoonwalker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,68 @@ | ||
| import promptSync from 'prompt-sync'; | ||
| import promptSync from "prompt-sync"; | ||
| const prompt = promptSync(); | ||
|
|
||
| // Exchange rate for EUR/USD (How much 1 EUR is in USD) | ||
| const EUR_USD_RATE = 1.1643; | ||
|
|
||
| // Menu display | ||
| conole.log("Hello and welcome to the currency converter. Please choose: "); | ||
| console.log("Hello and welcome to the currency converter. Please choose:"); | ||
| console.log("1: Convert EUR to USD"); | ||
| console.log("2: Convert USD to EUR"); | ||
| const menuSelection = prompt("Select your option [1 or 2]: "); | ||
| console.log("3: Display current exchange rate"); | ||
|
|
||
| const menuSelection = prompt("Select your option [1, 2 or 3]: "); | ||
| console.log("\n"); | ||
|
|
||
| if (menuSelection === "1") { | ||
| if (menuSelection === "") { | ||
| console.log("Invalid option. Please choose 1, 2, or 3."); | ||
| } else if (menuSelection === "1") { | ||
| // EUR to USD | ||
| const eurAmountInput = prompt("Enter amount in EUR: "); | ||
| const eurAmountNum = Number(eurAmountInput); | ||
| if (Number.isNaN(eurAmountNum) || eurAmountNum > 0) { | ||
|
|
||
| if (eurAmountInput === "") { | ||
| console.log("Please enter a valid positive number for the amount."); | ||
| } else { | ||
| const usdAmount = eurAmountNum * EUR_USD_RATE; | ||
| console.log(eurAmountNum.toFixed(2) + ' EUR is equal to ' + usdAmount.toFixed(2) + ' USD.'); | ||
| const eurAmountNum = Number(eurAmountInput); | ||
|
|
||
| if (Number.isNaN(eurAmountNum) || eurAmountNum <= 0) { | ||
| console.log("Please enter a valid positive number for the amount."); | ||
| } else { | ||
| const usdAmount = eurAmountNum * EUR_USD_RATE; | ||
| console.log( | ||
| eurAmountNum.toFixed(2) + | ||
| " EUR is equal to " + | ||
| usdAmount.toFixed(2) + | ||
| " USD." | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| } else if (menuSelection === "2") { | ||
| // USD to EUR | ||
| const usdAmountInput = prompt("Enter amount in USD: "); | ||
| const usdAmountNum = Number(usdAmountInput); | ||
| if (Number.isNaN(usdAmountNum) || usdAmountNum < 0) { | ||
|
|
||
| if (usdAmountInput === "") { | ||
| console.log("Please enter a valid positive number for the amount."); | ||
| } else { | ||
| const eurAmount = usdAmountNum / eur_usd_rate; | ||
| console.log(usdAmountNum.toFixed(2) + ' USD is equal to ' + usdAmountNum.toFixed(2) + ' EUR.'); | ||
| const usdAmountNum = Number(usdAmountInput); | ||
|
|
||
| if (Number.isNaN(usdAmountNum) || usdAmountNum <= 0) { | ||
| console.log("Please enter a valid positive number for the amount."); | ||
| } else { | ||
| const eurAmount = usdAmountNum / EUR_USD_RATE; | ||
| console.log( | ||
| usdAmountNum.toFixed(2) + | ||
| " USD is equal to " + | ||
| eurAmount.toFixed(2) + | ||
| " EUR." | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| } else if (menuSelection === "3") { | ||
| // Display current exchange rate | ||
| console.log("Current exchange rate: 1 EUR = " + EUR_USD_RATE.toFixed(4) + " USD"); | ||
|
|
||
| } else { | ||
| console.log("Invalid selection. Please choose either 1 or 2."); | ||
| console.log("Invalid option. Please choose 1, 2, or 3."); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.