-
Notifications
You must be signed in to change notification settings - Fork 19
Muna Naher ass.week02 #9
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
base: main
Are you sure you want to change the base?
Conversation
remarcmij
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @MunaNasher, apart from the indentation, the tasks 1 and 2 are fine. However, there is still any issue with task 3 that I would like you to fix. Good luck!
| import promptSync from 'prompt-sync'; | ||
| const prompt = promptSync(); | ||
|
|
||
| let year = prompt("Enter a year:"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is customary to use a space after a colon:
| let year = prompt("Enter a year:"); | |
| let year = prompt("Enter a year: "); |
| year = Number(year); | ||
|
|
||
| // check the input vaildation | ||
| if (isNaN(year) || year < 1 || year > 9999) { | ||
| console.log("Invalid year!"); | ||
| } else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use indentation to make your code more readable and easier to understand, refer to the Code Style section of the learning materials.
https://hub.hackyourfuture.nl/Code-style-Basics-2b050f64ffc9807d912ed59b0c72440d
| year = Number(year); | |
| // check the input vaildation | |
| if (isNaN(year) || year < 1 || year > 9999) { | |
| console.log("Invalid year!"); | |
| } else { | |
| year = Number(year); | |
| // check the input vaildation | |
| if (isNaN(year) || year < 1 || year > 9999) { | |
| console.log("Invalid year!"); | |
| } else { |
| const isAdmin = username === "admin" && password === "Hack1234"; | ||
| const isUser = username === "user" && password === "7654321"; | ||
|
|
||
| if (isAdmin || isUser) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation:
| const isAdmin = username === "admin" && password === "Hack1234"; | |
| const isUser = username === "user" && password === "7654321"; | |
| if (isAdmin || isUser) { | |
| const isAdmin = username === "admin" && password === "Hack1234"; | |
| const isUser = username === "user" && password === "7654321"; | |
| if (isAdmin || isUser) { |
| } | ||
|
|
||
|
|
||
| EUR_USD_RATE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this line?
| } else { | ||
| const eurAmount = usdAmountNum / eur_usd_rate; | ||
| const eurAmount = usdAmountNum / EUR_USD_RATE; // eur_usd_rate is not defined, it should be EUR_USD_RATE, Bug3 | ||
| console.log(usdAmountNum.toFixed(2) + ' USD is equal to ' + usdAmountNum.toFixed(2) + ' EUR.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I run your converter, it doesn't produce correct results for USD to EUR:
% node converter.js
Hello and welcome to the currency converter. Please choose:
1: Convert EUR to USD
2: Convert USD to EUR
Select your option [1 or 2]: 2
Enter amount in USD: 1
1.00 USD is equal to 1.00 EUR.
1 USD !== 1 EUR
No description provided.