I recently did a beginner JS tutorial (here) that was very informative. As one of the "bonus rounds", it asks you to add a bunch of different cities to the mix.
After adding more cities, I basically just copied the JS and added it to the next line - but that makes it look VERY sloppy and repetitive. I am curious if there is a way to clean it up? I tried creating a function to call from within the timestamp function (say "function addZero" that adds the zero before the single digit number if less than 10). Also same thing with calling the timestamp function and setting its interval.. each of them are called 6 times and it's just messy. Not sure if that's able to be cleaned up.
On top of the question of having cleaner code, besides the "Seattle" timestamp, the rest go over the 24 hour interval (that's not how time works!). I'm thinking it has to do with adding the "+ number" to the hours to set the city's time zone. They're also all set to being PM for some reason, even though the code says it shouldn't be like that.
I know it's a lot, but hopefully if anyone is bored they can give me an idea of what I'm clearly doing wrong.
Here is the JSFiddle Link to the code - with multiple time zones.
Fake code to submit this question.
I really appreciate anyone's input!
Keith
Aucun commentaire:
Enregistrer un commentaire