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

id, title, challengeType, dashedName
id title challengeType dashedName
69a890af247de743333bd4ce Challenge 225: No Consecutive Repeats 28 challenge-225

--description--

Given a string, determine if it has no repeating characters.

  • A string has no repeats if it does not have the same character two or more times in a row.

--hints--

hasNoRepeats("hi world") should return true.

assert.isTrue(hasNoRepeats("hi world"));

hasNoRepeats("hello world") should return false.

assert.isFalse(hasNoRepeats("hello world"));

hasNoRepeats("abcdefghijklmnopqrstuvwxyz") should return true.

assert.isTrue(hasNoRepeats("abcdefghijklmnopqrstuvwxyz"));

hasNoRepeats("freeCodeCamp") should return false.

assert.isFalse(hasNoRepeats("freeCodeCamp"));

hasNoRepeats("The quick brown fox jumped over the lazy dog.") should return true.

assert.isTrue(hasNoRepeats("The quick brown fox jumped over the lazy dog."));

hasNoRepeats("Mississippi") should return false.

assert.isFalse(hasNoRepeats("Mississippi"));

--seed--

--seed-contents--

function hasNoRepeats(str) {

  return str;
}

--solutions--

function hasNoRepeats(str) {
  for (let i = 1; i < str.length; i++) {
    if (str[i] === str[i - 1]) {
      return false;
    }
  }
  return true;
}