Conversation
dardecena
left a comment
There was a problem hiding this comment.
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.
| 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}!`; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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.
| export function giveCompliment(name) { | ||
| const i = Math.floor(Math.random() * compliments.length); | ||
| return `You are ${compliments[i]}, ${name}!`; | ||
| } |
There was a problem hiding this comment.
This is a duplicate file of the previous one. It's good practice to clean up your files before submitting your assignments.
| export function calculateDogAge(humanYears) { | ||
| return humanYears * 7; |
There was a problem hiding this comment.
Nice try. You are almost there.
Take another look at the requirements, the function should return a string. What does your function 'calculateDogAge' return?
| 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!` | ||
| ); |
There was a problem hiding this comment.
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.
| function main() { | ||
| const initialCart = ["bananas", "milk"]; | ||
| console.log(addToShoppingCart(initialCart, "chocolate")); | ||
| console.log(addToShoppingCart(initialCart, "waffles")); |
There was a problem hiding this comment.
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.
| export function calculateTotalPrice(cart) { | ||
| let total = 0; | ||
| for (const key in cart) { | ||
| total += cart[key]; | ||
| } | ||
| return `Total: €${total}`; | ||
| } |
There was a problem hiding this comment.
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); |
| const expected = "Total: €14.49"; | ||
| const actual = calculateTotalPrice(cartForParty); | ||
| console.assert(actual === expected); |
| export function filterPrivateData(records) { | ||
| return records.map(({ name, occupation, email }) => ({ | ||
| name, | ||
| occupation, | ||
| email, | ||
| })); | ||
| } |
There was a problem hiding this comment.
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?
No description provided.