Ad
  • Custom User Avatar

    I think the comments was to discuss the actual kata and not made up requirements, but I'll offer my two cents.

    I'm not sure if your underlying suggestion is to use JS Intl limited features to pluralize/translate the units, but internacionalization/localization is not trivial and the proper way to go is to use a library for it. Even for a simple kata like this we would need the following features:

    • Word translations (not just the time units, also the "and" + "now")
    • Handle whitespace (not all languages use it)
    • Pluralization
    • Handle enum separator (not all languages use a comma)
    • Handle the formatting of the number (not all languages use arabic numbers for time, but even then we would likely need separators for values >= 1000)

    So it's not like I would need to reimplement a one-line function if I wanted to localize to, let's say, Japanese. I would probably need to scrap that function altogether and use a completely different approach.

    My take when approaching these katas is to use code that is readable and extensible. And stick to the most simple solution posible. A readable one-liner is not a bad take here IMO