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.5 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
68b1f72371a5ac895ac70a0a Challenge 44: String Mirror 28 challenge-44

--description--

Given two strings, determine if the second string is a mirror of the first.

  • A string is considered a mirror if it contains the same letters in reverse order.
  • Treat uppercase and lowercase letters as distinct.
  • Ignore all non-alphabetical characters.

--hints--

isMirror("helloworld", "helloworld") should return false.

assert.isFalse(isMirror("helloworld", "helloworld"));

isMirror("Hello World", "dlroW olleH") should return true.

assert.isTrue(isMirror("Hello World", "dlroW olleH"));

isMirror("RaceCar", "raCecaR") should return true.

assert.isTrue(isMirror("RaceCar", "raCecaR"));

isMirror("RaceCar", "RaceCar") should return false.

assert.isFalse(isMirror("RaceCar", "RaceCar"));

isMirror("Mirror", "rorrim") should return false.

assert.isFalse(isMirror("Mirror", "rorrim"));

isMirror("Hello World", "dlroW-olleH") should return true.

assert.isTrue(isMirror("Hello World", "dlroW-olleH"));

isMirror("Hello World", "!dlroW !olleH") should return true.

assert.isTrue(isMirror("Hello World", "!dlroW !olleH"));

--seed--

--seed-contents--

function isMirror(str1, str2) {

  return str1;
}

--solutions--

function isMirror(str1, str2) {
  const clean1 = str1.replace(/[^a-zA-Z]/g, "");
  const clean2 = str2.replace(/[^a-zA-Z]/g, "");
  return clean1.split("").reverse().join("") === clean2;
}