Menu

Post image 1
Post image 2
1 / 2
0

Reading my own paycheck: turning gross salary into hourly rate in JavaScript

DEV Community·levent çelik·about 1 month ago
#p4KAAQ3X
Reading 0:00
15s threshold

I switched companies last year and the offer letter quoted my salary as an annual gross number. The recruiter was confident, the email looked clean, and yet I still wanted to know one thing my brain refuses to compute on the fly: "how much per hour is that, really?" I ended up writing a tiny script to do it for me, and then kept extending it until I had a small toolkit for reasoning about my own pay. Sharing the bits I now keep in a paycheck.ts file in case anyone else finds it useful. The naive conversion The number every salary site quotes is annual gross divided by 2,080. Forty hours times fifty-two weeks. As code: function grossHourly ( annual ) { return annual / 2080 ; } grossHourly ( 95000 ); // 45.67 Enter fullscreen mode Exit fullscreen mode Fine for a back-of-the-envelope. But anyone who has actually filled out a timesheet knows that 2,080 is a fiction. You probably take vacation, you have public holidays, and you almost certainly do not bill for sick days.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More