mediumDev Processes#150

OTA update gate (runtimeVersion)

Prompt

Model the server-side gate of an OTA system like EAS Update. Given:

  • binary = { runtimeVersion, channel } — what the installed app reports
  • updates = [{ id, runtimeVersion, channel, createdAt }] — published updates (createdAt is a number)

Write selectUpdate(updates, binary):

  1. An update is compatible only if BOTH runtimeVersion and channel match the binary exactly
  2. Return the newest compatible update (highest createdAt), or null if none

Hints

Solution

Your Code

15 min

Tests

Click Run to test your code