You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unless I've misunderstood it seems like this code is there to ensure that you have sequentially increasing IDs. Each new ID you add should be one bigger than the previous biggest. It's clever code, and good use of higher-order array methods!
However I think it may be unnecessary—since you are keeping track of the ID in a variable outside the handler you will always have access to the previous ID, and so can just increment that each time. E.g.
The id variable will stick around for as long as your server is running and persist between POST requests, so you can rely on it always having the right value.
The text was updated successfully, but these errors were encountered:
microblogging_site-DASE/routes/addPost.js
Lines 44 to 61 in 6397495
Unless I've misunderstood it seems like this code is there to ensure that you have sequentially increasing IDs. Each new ID you add should be one bigger than the previous biggest. It's clever code, and good use of higher-order array methods!
However I think it may be unnecessary—since you are keeping track of the ID in a variable outside the handler you will always have access to the previous ID, and so can just increment that each time. E.g.
The
id
variable will stick around for as long as your server is running and persist betweenPOST
requests, so you can rely on it always having the right value.The text was updated successfully, but these errors were encountered: