-
-
Notifications
You must be signed in to change notification settings - Fork 306
NW5-Manchester-Khadar-M-Dagal-Node-W3 #194
base: master
Are you sure you want to change the base?
Conversation
Ara225
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've had to flag quite a few thing this time. Don't be discouraged, I'm sure you'll figure it all out, you're a strong student in the end of the day. Only genral note is to have a look into .gitignore files, as you've accidently commited the node_modules folder and that is considered bad practice. See https://www.freecodecamp.org/news/gitignore-what-is-it-and-how-to-add-to-repo/ and https://github.com/github/gitignore
| bookings.push(newBooking); | ||
| res.status(200).send(bookings); | ||
| } else { | ||
| res.status(400).send("Some information is missing"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice :)
| //Level 3 search by date | ||
|
|
||
| // convet date to numbers | ||
| const dateToNumber = (date) => Number(date.replaceAll("-", "")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intresting idea, and as the date format they ask you to use is non standard (normally years are last e.g. 27/01/2023) should work alright, but this isn't the correct way to do it. You'd want to make both dates into a date object wether the native JavaScript date object or a moment.js one, and then compare it
| // level 4 | ||
|
|
||
| const emailValidation = (email) => { | ||
| email.includes("@") ? email : "Not valid email"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lot more to email validation than this I'm afraid, worth reading up/using a libary. Also, it would be best to return a boolean from this function. At the moment, this function always returns a non empty string so it will always evaluate to true.
| // only checking when the checkOutDate is earlier then the checkIndate | ||
| if (checkOutDate < checkInDate) { | ||
| return "!! checkOutDate can not be earlier then the CheckInDate"; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this logic is flawed I'm afraid, The result of this function will be a value that JavaScript considers True if checkOutDate is earlier than CheckInDate and undefined otherwise . Date comparsion in this way is also flawed, have a look at the Date object https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
master