DEV Community

Discussion on: Daily Challenge #54 - What century is it?

Collapse
 
savagepixie profile image
SavagePixie

I like your approach, it looks very clean.

This is probably too fringe to matter in most contexts, but wouldn't your function return 111st for the year 11,092?

Collapse
 
gnsp profile image
Ganesh Prasad

It would, indeed. Thanks for pointing out. Now I have fixed it and added a new test case.

OLD SOLUTION (Line 7)

const suffix = Math.floor(cent / 10) === 1 ? 'th'

UPDATED SOLUTION (Line 7)

const suffix = Math.floor(cent / 10) % 10 === 1 ? 'th'