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
75 lines
1.3 KiB
Markdown
75 lines
1.3 KiB
Markdown
---
|
|
id: 69a890af247de743333bd4ce
|
|
title: "Challenge 225: No Consecutive Repeats"
|
|
challengeType: 28
|
|
dashedName: 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`.
|
|
|
|
```js
|
|
assert.isTrue(hasNoRepeats("hi world"));
|
|
```
|
|
|
|
`hasNoRepeats("hello world")` should return `false`.
|
|
|
|
```js
|
|
assert.isFalse(hasNoRepeats("hello world"));
|
|
```
|
|
|
|
`hasNoRepeats("abcdefghijklmnopqrstuvwxyz")` should return `true`.
|
|
|
|
```js
|
|
assert.isTrue(hasNoRepeats("abcdefghijklmnopqrstuvwxyz"));
|
|
```
|
|
|
|
`hasNoRepeats("freeCodeCamp")` should return `false`.
|
|
|
|
```js
|
|
assert.isFalse(hasNoRepeats("freeCodeCamp"));
|
|
```
|
|
|
|
`hasNoRepeats("The quick brown fox jumped over the lazy dog.")` should return `true`.
|
|
|
|
```js
|
|
assert.isTrue(hasNoRepeats("The quick brown fox jumped over the lazy dog."));
|
|
```
|
|
|
|
`hasNoRepeats("Mississippi")` should return `false`.
|
|
|
|
```js
|
|
assert.isFalse(hasNoRepeats("Mississippi"));
|
|
```
|
|
|
|
# --seed--
|
|
|
|
## --seed-contents--
|
|
|
|
```js
|
|
function hasNoRepeats(str) {
|
|
|
|
return str;
|
|
}
|
|
```
|
|
|
|
# --solutions--
|
|
|
|
```js
|
|
function hasNoRepeats(str) {
|
|
for (let i = 1; i < str.length; i++) {
|
|
if (str[i] === str[i - 1]) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
```
|