• Home
  • Blog
  • Projects
  • Back

    Example tech test2026-08-09

    Following on from my previous article hypothesising about the ideal tech test task, I’ve tried adapting an example from Code Your Future’s bank of mock interview questions to fit my own guidelines. This is presented below, but if this were used for real I would also expect the candidate to be provided with skeleton functions to be completed and tests that the candidate can run as they go (including the examples as test cases).

    Its solvable using no external libraries, involves the use of JS’s built-in date handling (something that I at least have to google every time), a second task that builds on the first, a couple of easy mistakes to make, and should be solvable within an hour.

    Task 1 description

    Write a function that takes a historical date as input and returns the century in which that date falls. You can assume that all inputs will be Gregorian Calendar dates in the Anno Domini era, or, in other words, normal western calendar dates where the year is a positive number.

    A working solution should correctly determine that:

    1. 4th July 1776 was in the 18th century.
    2. 15th June 1215 was in the 13th century.
    3. 8th May 1945 was in the 20th century.
    4. 31st December 2000 was in the 20th century.
    5. 1st January 2001 was in the 21st century.
    6. 1st August 799 was in the 8th century.

    Task 2 description

    Write a function that, given an array of dates in the same format, returns an integer representing the largest gap between two represented centuries.

    So given:

    1. 4th July 1776.
    2. 15th June 1215.
    3. 8th May 1945.

    We would find that:

    1. 4th July 1776 -> 18th century
    2. 15th June 1215 -> 13th century
    3. 8th May 1945 -> 20th century

    And because 20 - 13 = 7, the function should return 7.

    Similarly, ["5. 1st January 2001", "1st August 799"] should return 21 - 8 which is 13.