Conversation
📝 HackYourFuture auto gradeAssignment Score: 13 / 100 ❌Status: ❌ Not passed Test Details |
| const BASE_URL = "https://www.thecocktaildb.com/api/json/v1/1"; | ||
|
|
||
| // Add helper functions as needed here | ||
| function checkAlcohol(alcoholic) { |
There was a problem hiding this comment.
Very good, you encapsulated it in a function, this make your code reusable
| return alcoholic === "Alcoholic" ? "Yes" : "No"; | ||
| } | ||
|
|
||
| function getIngredients(drink) { |
There was a problem hiding this comment.
Very good, you encapsulated it in a function, this make your code reusable
| return ingredients.join("\n"); | ||
| } | ||
|
|
||
| function createMarkdown(drink) { |
There was a problem hiding this comment.
Very good, you encapsulated it in a function, this make your code reusable
| ].join("\n"); | ||
| } | ||
|
|
||
| function formatMarkdown(drinks) { |
There was a problem hiding this comment.
Very good, you encapsulated it in a function, this make your code reusable
| } | ||
|
|
||
| // 2. Generate markdown content to match the examples | ||
| const markdown = formatMarkdown(data.drinks); |
There was a problem hiding this comment.
Very good, you encapsulated it in a function, this make your code reusable
| const response = await fetch(`${BASE_URL}/posts/hello`); | ||
| if (!response.ok) { | ||
| throw new Error( | ||
| `Failed to get hello: HTTP ${response.status} ${response.statusText}`, |
|
|
||
| if (!response.ok) { | ||
| throw new Error( | ||
| `Failed to get user: HTTP ${response.status} ${response.statusText}`, |
| }); | ||
| if (!response.ok) { | ||
| throw new Error( | ||
| `Failed to create user: HTTP ${response.status} ${response.statusText}`, |
|
|
||
| if (!response.ok) { | ||
| throw new Error( | ||
| `Failed to login: HTTP ${response.status} ${response.statusText}`, |
|
|
||
| if (!response.ok) { | ||
| throw new Error( | ||
| `Failed to create post: HTTP ${response.status} ${response.statusText}`, |
|
|
||
| if (!response.ok) { | ||
| throw new Error( | ||
| `Failed to update post: HTTP ${response.status} ${response.statusText}`, |
|
|
||
| if (!response.ok) { | ||
| throw new Error( | ||
| `Failed to delete post: HTTP ${response.status} ${response.statusText}`, |
JQnetherlands
left a comment
There was a problem hiding this comment.
Hello, Jawad.
I will start with the good news! you have passed both task successfully, you almost have exceeds expectations ( almost 5 starts), now I will go on with the nices to have.
I really like how you use functions to encapsulate certain features for the markdown , because this make your code reusable you can use it for other projects , where you need to do a markdown or for personal use, your code is clean and very easy to follow. Congratulations
About task 2, all your functions accomplish their goal , well done, each of one shows you do understand the CRUD and HTTP actions and what each Method needs to successfully fetch to the back end (GET, POST, UPDATE, DELETE).
The only feedback I have to write better code is the following:
Right now you have ---> Failed to delete post: HTTP ${response.status} ${response.statusText}
That would be ---> Failed to delete post: HTTP 403 forbidden
Do you think it is clear enough information for the user to know what went wrong?
Can you imagine a better statement for the user?
for example this you could do if you change your code a bit, I will give you the final expected output that I am talking about:
clearer output ---> Failed to delete post: HTTP 403 You can only modify your own posts
Do you see the difference? can you imagine how you could make your code give that example? HINT: maybe an inline conditional , do you know which one?
That you could apply to each function to make it more user friendly.
Again, you did super well overall, you passed successfully and almost beyond expectations, please be proud of yourself and keep the good work! Congratulations
No description provided.