bugger.
All challenges/JavaScripteasythe-fraction-that-moves-a-day-v1
THE INVESTIGATION

The fraction that moves a day

Subtracting less than a day unexpectedly moves a calendar reminder to yesterday.

JavaScriptLanguage semanticsRegression testing

What’s going wrong

Input is a JSON array of at most 100 objects {at, days}. at is a valid UTC ISO timestamp in YYYY-MM-DDTHH:mm:ss.sssZ form with year 2000..2099. days is either a finite number in -1000..1000, a string, null or a boolean. Convert strings with Number, including its normal empty/whitespace-to-zero behavior; finite converted results are within -1000..1000. Null, booleans and nonfinite conversion results are invalid and produce null. For a valid amount, discard its fractional part toward zero BEFORE adding calendar days in UTC. Preserve the time of day and milliseconds. Return an array of normalized UTC ISO timestamps or null, one per row. Inputs never leave the Date range. Do not mutate the meaning of the supplied timestamp or round the final day-of-month.

Expected behavior

Normalize a numeric amount before combining it with calendar state.

Reproduction

01 Negative fraction
[{"at":"2024-06-15T09:30:00.000Z","days":-1.9}]
["2024-06-14T09:30:00.000Z"]
02 Whole day control
[{"at":"2024-06-15T09:30:00.000Z","days":2}]
["2024-06-17T09:30:00.000Z"]
03 Zero control
[{"at":"2024-06-15T09:30:00.000Z","days":0}]
["2024-06-15T09:30:00.000Z"]

Before you begin

  • JavaScript functions, arrays and objects
  • Build on explicit numeric meaning instead of relying on implicit representation behavior.

Need a nudge?

Reveal one investigation hint at a time. Try each clue before opening the next.

    The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.