Skip to content

Conversation

@MunaNasher
Copy link

No description provided.

@remarcmij remarcmij self-assigned this Jan 21, 2026
Copy link

@remarcmij remarcmij left a 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:");

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:

Suggested change
let year = prompt("Enter a year:");
let year = prompt("Enter a year: ");

Comment on lines +7 to +12
year = Number(year);

// check the input vaildation
if (isNaN(year) || year < 1 || year > 9999) {
console.log("Invalid year!");
} else {

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

Suggested change
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 {

Comment on lines +14 to +17
const isAdmin = username === "admin" && password === "Hack1234";
const isUser = username === "user" && password === "7654321";

if (isAdmin || isUser) {

Choose a reason for hiding this comment

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

Indentation:

Suggested change
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

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.');

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants