Skip to content
Tactiverge

◇ Sensors · loops and objects

Minimum, maximum, range

Track the lowest and highest readings in one pass and return them in an object.

  • Level 1 · Explorer
  • 4 tests
  • 🐞 debug variant
  • technically checked

Your task

A data logger on a weather station stores the day's air pressure readings. The summary screen shows the lowest value, the highest value and the range (highest minus lowest).

Write sensorRange(readings) that returns an object { min, max, range }. You may assume there is at least one reading.

Hints (0 of 2 shown)

    What gets checked

    • sensorRange([3, 7, 1, 9]) → { min: 1, max: 9, range: 8 }
    • sensorRange([1013.2, 1009.8, 1015.1]) → { min: 1009.8, max: 1015.1, range: ≈ 5.3 (± 1e-9) }

    Plus 2 hidden tests for edge cases. They run in the sandbox like the others; only the result is shown.

    Tab indents · Esc then Tab leaves the editor · Ctrl/⌘ Enter runs · Ctrl/⌘ Shift Enter checks · Ctrl/⌘ / comments

    Starting the sandbox…

    Press Run to see what your program prints.

    Your code runs only in this browser, inside an isolated sandbox with no network access, and stops after 3 s. Nothing you type is sent to Tactiverge; drafts and progress are saved in this browser only.