Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.6 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
691b559495c5cb5a37b9b487 Challenge 127: Speed Check 28 challenge-127

--description--

Given the speed you are traveling in miles per hour (MPH), and a speed limit in kilometers per hour (KPH), determine whether you are speeding and if you will get a warning or a ticket.

  • 1 mile equals 1.60934 kilometers.
  • If you are traveling less than or equal to the speed limit, return "Not Speeding".
  • If you are traveling 5 KPH or less over the speed limit, return "Warning".
  • If you are traveling more than 5 KPH over the speed limit, return "Ticket".

--hints--

speedCheck(30, 70) should return "Not Speeding".

assert.equal(speedCheck(30, 70), "Not Speeding");

speedCheck(40, 60) should return "Warning".

assert.equal(speedCheck(40, 60), "Warning");

speedCheck(40, 65) should return "Not Speeding".

assert.equal(speedCheck(40, 65), "Not Speeding");

speedCheck(60, 90) should return "Ticket".

assert.equal(speedCheck(60, 90), "Ticket");

speedCheck(65, 100) should return "Warning".

assert.equal(speedCheck(65, 100), "Warning");

speedCheck(88, 40) should return "Ticket".

assert.equal(speedCheck(88, 40), "Ticket");

--seed--

--seed-contents--

function speedCheck(speedMph, speedLimitKph) {
  return speedMph;
}

--solutions--

function speedCheck(speedMph, speedLimitKph) {
  const speedKph = speedMph * 1.60934;

  if (speedKph <= speedLimitKph) {
    return "Not Speeding";
  }

  const over = speedKph - speedLimitKph;

  if (over <= 5) {
    return "Warning";
  }

  return "Ticket";
}