3 ms·
I would highly consider revising your js/time.js if you want to be consider for a javascript development position, there are some painful issues here. http://o
by Meph504 10y ago
I would highly consider revising your js/time.js if you want to be consider for a javascript development position, there are some painful issues here.
http://o23.io/js/time.js http://o23.io/js/time.js
please see
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- oliv__ 10y agoI am aware of toLocaleTimeString() but I chose to do it manually because I wanted to display time in this particular format, regardless of the user's locale, and because of oddities like this one for Safari users: http://stackoverflow.com/questions/5471508/javascript-on-mac-safari-tolocaletimestring-oddities http://stackoverflow.com/questions/5471508/javascript-on-mac...
- magic_beans 10y agoYou really don't need to be displaying your user's time at all. It's kind of distracting.
- Meph504 10y agowhen you pass the local "en-us" that means you use that, and not the user's locale. the formatting you desired, can also be easily defined with the options argument. see (https://jsfiddle.net/prn4823b/1/ https://jsfiddle.net/prn4823b/1/) but these methods, are pretty new, so say we disregard them for a minute. The serious issue to take note of here, is that you are defining everything, in a function you are calling every second. you don't need a new date object every second, you don't need to redefine those arrays, you also instead of doing one conditional for amPm, and hour formatting, are doing each in their own ternary. I'm not trying to be hyper critical, but I did to you, just like I do with most candidates that apply with me, and seeing this, it would make me doubt your statements about javascript. I would also argue, that showing the time here is a bit odd, as typically for something like this, it would be the time of the contents last update, not their own time, they have a clock already. Best of luck with getting a gig.
- oliv__ 10y agoYou're right. Your code is much cleaner. Otherwise the time itself is just something I liked having there; my OS has a clock too, I'm aware of that.