Skip to content
This repository was archived by the owner on Aug 17, 2024. It is now read-only.

Conversation

@AhmedMohamed809
Copy link

Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in HOW_TO_MARK.md in the root of this repository

Your Details

  • Your Name: Ahmed Mohamed
  • Your City: Manchester
  • Your Slack Name: Ahmed Mohamed

Homework Details

  • Module: NodeJS
  • Week: 3

Notes

  • What did you find easy?

  • What did you find hard?

  • What do you still not understand?

  • Any other notes?

Copy link

@AltomHussain AltomHussain left a comment

Choose a reason for hiding this comment

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

Great job mate :)

//Create a new booking
app.post("/booking", (req, resp) => {
const newBooking = req.body;
console.log(newBooking);

Choose a reason for hiding this comment

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

You could have cleared your logs once you are done building.

newBooking.checkOutDate
) {
bookings.push(newBooking);
resp.send("New Booking has been added >>");

Choose a reason for hiding this comment

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

In the response message, you could also return the values from the array to make sure you have updated them.

app.get("/booking/:id", function (request, response) {
const bookingID = +request.params.id;
const fliterBooking = bookings.find((booking) => booking.id === bookingID);
if (!fliterBooking) {

Choose a reason for hiding this comment

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

I don't think you should use this syntax !fliterBooking in your if statement to validate because it might work when the find function returns a value.
The only time you should use this syntax is when you know your function returns true or false but the find method does not return true or false but it returns a value or undefined so you should use undefined to compare in your if statement I believe.

You can read the "Return Value` on this section about the value that the find function retuns
https://www.w3schools.com/jsref/jsref_find.asp#:~:text=The%20find()%20method%20returns,if%20no%20elements%20are%20found.

@AltomHussain
Copy link

Oh sorry, one more thing! You shouldn't have pushed your node_modules folder, you can search on google on how to ignore a file or folder in get. So you can learn how to ignore a file or folder when you don't want to push something. Node modules are quite big so you don't need to push them just keep them locally.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants