THE INVESTIGATION
The ticks that forget the past
JavaScript timestamp sorting bug with negative numbers
A chart deduplicates timestamps but puts dates before the epoch after modern ones.
JavaScriptLanguage semanticsRegression testing
What’s going wrong
Input is a JSON array of at most 200 finite numbers between -10^12 and 10^12. They are tick positions, including negative timestamps and fractions. Return one JSON array of distinct numeric positions in ascending numeric order. Equal numbers appear once; zero is an ordinary tick. The input need not be sorted. No rendering or date parsing is required.
Expected behavior
Separate dictionary enumeration order from the numeric ordering the product promises.
Reproduction
01 Before and after the epoch
[-2,0,3]
[-2,0,3]
02 Positive small tick control
[9,2,1]
[1,2,9]
03 Empty chart
[]
[]
Before you begin
- JavaScript functions, arrays and objects
- Begin with object keys, array transformations and numeric comparison.
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.
Ready when you are
Every fix starts with a failing test.
Read the report, then sign in to start your investigation.