Timestamp Microservice - why multiple .js files?

So, I felt pretty much lost in building the app, essentially because I don’t quite understand why all the people are making more than one .js file - app.js, timestamp.js, router.js etc, and, more embarassing, I don’t understand the code they made… :flushed: Since it was hard for me to grasp the philosophy behind that, I decided to just try and make it work, and after I’m done with the first working version, I could ask for help.

These are my GitHub repository and Heroku app:


Please feel free to look at it, it seems to be working…

What’s more important - could anyone explain why should I make multiple .js files instead of one for this project - what’s the benefit? Also, if someone would be so kind and explain me what would it look like if my server.js was separated into two or more files - I think I still don’t understand the concept, or the “big picture” behind all this… All in all, an example (simpler - better) and an explanation would be fantastic.:relaxed:

For this project, I also have one JS file, which is server.js.
You don’t really need extra JS file, unless you want to embellish it with more interaction for the app.

Here’s my app, which is essentially the same format as yours.

I think you are one right track.

Also there appears a bug in your code: when I type October 27 1989 I get

unix: 8521000243200,
natural: "October 1, 271989"

Thanks for your reply, but that’s not what I’m getting:

{“unix”:625449600,“natural”:“October 27, 1989”}

Although, I’m already aware of one bug - if I pass 29 February, it’ll happily accept it as a valid date… Well, tomorrow I’ll check that, it’s late in the evening/early morning in my country. But my main problem is the routing philosophy, not a particular bug in app…

My bad, I meant if I type October271989 without spaces, then I get that response.

1 Like

Fixed, thanks for the tip.