Skip to content

Conversation

@Hadidreem17
Copy link

No description provided.

@dardecena dardecena self-requested a review September 16, 2025 16:22
Copy link

@dardecena dardecena left a comment

Choose a reason for hiding this comment

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

Great effort! You are almost there. Please attempt exercise 3 and 4 again.

I've added some additional comments for you to reflect on. If you need more details, please get in touch with me on Slack.

Comment on lines +6 to +20
export function giveCompliment(name) {
const compliments = [
"great",
"awesome",
"fantastic",
"brilliant",
"wonderful",
"amazing",
"incredible",
"outstanding",
"marvelous",
"exceptional"
];
const i = Math.floor(Math.random() * compliments.length);
return `You are ${compliments[i]}, ${name}!`;

Choose a reason for hiding this comment

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

Great job!
The only minor comment I have here is that it's good practice to maintain the indentation (line 6) to make the code readable and maintainable
** I just saw that in the duplicate file you made the fix. 😄

// TODO substitute your own name for "HackYourFuture"
const myName = 'HackYourFuture';

const myName = "HackYourFuture";

Choose a reason for hiding this comment

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

Don't forget to read the assignment instructions and check if your code meets the requirements.
In this case, it was requested to replace the string "HackYourFuture" with your name.

Comment on lines +14 to +17
export function giveCompliment(name) {
const i = Math.floor(Math.random() * compliments.length);
return `You are ${compliments[i]}, ${name}!`;
}

Choose a reason for hiding this comment

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

This is a duplicate file of the previous one. It's good practice to clean up your files before submitting your assignments.

Comment on lines +1 to +2
export function calculateDogAge(humanYears) {
return humanYears * 7;

Choose a reason for hiding this comment

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

Nice try. You are almost there.

Take another look at the requirements, the function should return a string. What does your function 'calculateDogAge' return?

Comment on lines +6 to +14
const myAge = 25;
console.log(
`If you are ${myAge} years old, that's ${calculateDogAge(myAge)} in dog years!`
);

const yourAge = 40;
console.log(
`If you are ${yourAge} years old, that's ${calculateDogAge(yourAge)} in dog years!`
);

Choose a reason for hiding this comment

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

This is not necessary, the function 'calculateDogAge' should return the console.log(). Think about the string that is the expected result, and where in the code it should be triggered.

Comment on lines +15 to +18
function main() {
const initialCart = ["bananas", "milk"];
console.log(addToShoppingCart(initialCart, "chocolate"));
console.log(addToShoppingCart(initialCart, "waffles"));

Choose a reason for hiding this comment

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

Why are the tests removed from the file?
Please restore the tests and remove the code that was added on lines 15-18 and lines 21-22.

Comment on lines +16 to 22
export function calculateTotalPrice(cart) {
let total = 0;
for (const key in cart) {
total += cart[key];
}
return `Total: €${total}`;
}

Choose a reason for hiding this comment

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

Great!

Challenge: What's another variable name you could replace 'key' with that would make the function more descriptive?

Line 16: Think about what types of situations where 'export' would be used. Is it applicable in this case?

console.log('\nTest 1: calculateTotalPrice should take one parameter');
// TODO replace this comment with your code
console.log("\nTest 1: calculateTotalPrice should take one parameter");
console.assert(calculateTotalPrice.length === 1);

Choose a reason for hiding this comment

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

:+1

Comment on lines +32 to +34
const expected = "Total: €14.49";
const actual = calculateTotalPrice(cartForParty);
console.assert(actual === expected);

Choose a reason for hiding this comment

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

👍

Comment on lines +18 to 24
export function filterPrivateData(records) {
return records.map(({ name, occupation, email }) => ({
name,
occupation,
email,
}));
}

Choose a reason for hiding this comment

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

Excellent! Great use of the map method.

Line 18: Think about what types of situations where 'export' would be used. Is it applicable in this case?

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