Closed Myonpasu closed 7 years ago
Changes LGTM - could you provide some example inputs and expected outputs? We can use these to make sure that the scaling works as expected, and I'll also include them as part of the unit test for this function.
Make sure to include the edge cases as they're the most important ones (eg, an input that results in a maximum scaled score)
Constants: MIN_SCALED_SCORE = 1 MAX_SCALED_SCORE = 10 SCORE_INCREMENT = 1 currentMin = 1 currentMax = 49
Edge cases (where there are two options, I would expect it to be the greater one thanks to JavaScript rounding): 1 -> 1 5.8 -> 1 or 2 10.6 -> 2 or 3 15.4 -> 3 or 4 20.2 -> 4 or 5 25 -> 5 or 6 29.8 -> 6 or 7 34.6 -> 7 or 8 39.4 -> 8 or 9 44.2 -> 9 or 10 49 -> 10
Some test values: 10.599999 -> 2 10.600001 -> 3 48.999999 -> 10 35 -> 8
New pull request
Fixed scaling and rounding for displayed scores and added compatibility with more general increments for discrete scoring systems.