2018-10-04 14:37:37 +01:00
|
|
|
---
|
|
|
|
id: af7588ade1100bde429baf20
|
|
|
|
title: Missing letters
|
|
|
|
challengeType: 5
|
2019-07-31 11:32:23 -07:00
|
|
|
forumTopicId: 16023
|
2018-10-04 14:37:37 +01:00
|
|
|
---
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --description--
|
|
|
|
|
2018-10-04 14:37:37 +01:00
|
|
|
Find the missing letter in the passed letter range and return it.
|
2020-11-27 19:02:05 +01:00
|
|
|
|
2018-10-04 14:37:37 +01:00
|
|
|
If all letters are present in the range, return undefined.
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --hints--
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
`fearNotLetter("abce")` should return "d".
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
```js
|
|
|
|
assert.deepEqual(fearNotLetter('abce'), 'd');
|
|
|
|
```
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
`fearNotLetter("abcdefghjklmno")` should return "i".
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
```js
|
|
|
|
assert.deepEqual(fearNotLetter('abcdefghjklmno'), 'i');
|
2018-10-04 14:37:37 +01:00
|
|
|
```
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
`fearNotLetter("stvwx")` should return "u".
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
```js
|
|
|
|
assert.deepEqual(fearNotLetter('stvwx'), 'u');
|
|
|
|
```
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
`fearNotLetter("bcdf")` should return "e".
|
2018-10-04 14:37:37 +01:00
|
|
|
|
|
|
|
```js
|
2020-11-27 19:02:05 +01:00
|
|
|
assert.deepEqual(fearNotLetter('bcdf'), 'e');
|
2018-10-04 14:37:37 +01:00
|
|
|
```
|
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
`fearNotLetter("abcdefghijklmnopqrstuvwxyz")` should return undefined.
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
```js
|
|
|
|
assert.isUndefined(fearNotLetter('abcdefghijklmnopqrstuvwxyz'));
|
|
|
|
```
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
# --seed--
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
## --seed-contents--
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
```js
|
|
|
|
function fearNotLetter(str) {
|
|
|
|
return str;
|
|
|
|
}
|
2018-10-04 14:37:37 +01:00
|
|
|
|
2020-11-27 19:02:05 +01:00
|
|
|
fearNotLetter("abce");
|
|
|
|
```
|
|
|
|
|
|
|
|
# --solutions--
|
2018-10-04 14:37:37 +01:00
|
|
|
|
|
|
|
```js
|
|
|
|
function fearNotLetter (str) {
|
|
|
|
for (var i = str.charCodeAt(0); i <= str.charCodeAt(str.length - 1); i++) {
|
|
|
|
var letter = String.fromCharCode(i);
|
|
|
|
if (str.indexOf(letter) === -1) {
|
|
|
|
return letter;
|
|
|
|
}
|
|
|
|
}
|
2018-10-08 01:01:53 +01:00
|
|
|
|
2018-10-04 14:37:37 +01:00
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
```
|