2021-06-15 00:49:18 -07:00
|
|
|
---
|
|
|
|
id: af7588ade1100bde429baf20
|
2021-07-21 20:53:20 +05:30
|
|
|
title: Encontrar as letras faltando
|
2021-06-15 00:49:18 -07:00
|
|
|
challengeType: 5
|
|
|
|
forumTopicId: 16023
|
|
|
|
dashedName: missing-letters
|
|
|
|
---
|
|
|
|
|
|
|
|
# --description--
|
|
|
|
|
2021-07-16 11:03:16 +05:30
|
|
|
Encontre a letra que falta no intervalo de letras passado e devolva-a.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
2021-07-16 11:03:16 +05:30
|
|
|
Se todas as letras estiverem presentes no intervalo, retorne `undefined`.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
# --hints--
|
|
|
|
|
2021-07-16 11:03:16 +05:30
|
|
|
`fearNotLetter("abce")` deve retornar a string `d`.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
```js
|
|
|
|
assert.deepEqual(fearNotLetter('abce'), 'd');
|
|
|
|
```
|
|
|
|
|
2021-07-16 11:03:16 +05:30
|
|
|
`fearNotLetter("abcdefghjklmno")` deve retornar a string `i`.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
```js
|
|
|
|
assert.deepEqual(fearNotLetter('abcdefghjklmno'), 'i');
|
|
|
|
```
|
|
|
|
|
2021-07-16 11:03:16 +05:30
|
|
|
`fearNotLetter("stvwx")` deve retornar a string `u`.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
```js
|
|
|
|
assert.deepEqual(fearNotLetter('stvwx'), 'u');
|
|
|
|
```
|
|
|
|
|
2021-07-16 11:03:16 +05:30
|
|
|
`fearNotLetter("bcdf")` deve retornar a string `e`.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
```js
|
|
|
|
assert.deepEqual(fearNotLetter('bcdf'), 'e');
|
|
|
|
```
|
|
|
|
|
2021-07-16 11:03:16 +05:30
|
|
|
`fearNotLetter("abcdefghijklmnopqrstuvwxyz")` deve retornar `undefined`.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
```js
|
|
|
|
assert.isUndefined(fearNotLetter('abcdefghijklmnopqrstuvwxyz'));
|
|
|
|
```
|
|
|
|
|
|
|
|
# --seed--
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
```js
|
|
|
|
function fearNotLetter(str) {
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
fearNotLetter("abce");
|
|
|
|
```
|
|
|
|
|
|
|
|
# --solutions--
|
|
|
|
|
|
|
|
```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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
```
|