2021-06-15 00:49:18 -07:00
|
|
|
---
|
|
|
|
id: a202eed8fc186c8434cb6d61
|
2021-07-21 20:53:20 +05:30
|
|
|
title: Inverter uma string
|
2021-06-15 00:49:18 -07:00
|
|
|
challengeType: 5
|
|
|
|
forumTopicId: 16043
|
|
|
|
dashedName: reverse-a-string
|
|
|
|
---
|
|
|
|
|
|
|
|
# --description--
|
|
|
|
|
2021-07-09 21:23:54 -07:00
|
|
|
Inverta a string fornecida.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
2021-07-26 23:39:21 +09:00
|
|
|
Você pode ter que transformar a string em um array antes de poder inverter.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
2021-07-09 21:23:54 -07:00
|
|
|
Seu resultado deve ser uma string.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
# --hints--
|
|
|
|
|
2021-07-09 21:23:54 -07:00
|
|
|
`reverseString("hello")` deve retornar uma string.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
```js
|
|
|
|
assert(typeof reverseString('hello') === 'string');
|
|
|
|
```
|
|
|
|
|
2021-07-09 21:23:54 -07:00
|
|
|
`reverseString("hello")` deve retornar a string `olleh`.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
```js
|
|
|
|
assert(reverseString('hello') === 'olleh');
|
|
|
|
```
|
|
|
|
|
2021-07-09 21:23:54 -07:00
|
|
|
`reverseString("Howdy")` deve retornar a string `ydwoH`.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
```js
|
|
|
|
assert(reverseString('Howdy') === 'ydwoH');
|
|
|
|
```
|
|
|
|
|
2021-07-09 21:23:54 -07:00
|
|
|
`reverseString("Greetings from Earth")` deve retornar a string `htraE morf sgniteerG`.
|
2021-06-15 00:49:18 -07:00
|
|
|
|
|
|
|
```js
|
|
|
|
assert(reverseString('Greetings from Earth') === 'htraE morf sgniteerG');
|
|
|
|
```
|
|
|
|
|
|
|
|
# --seed--
|
|
|
|
|
|
|
|
## --seed-contents--
|
|
|
|
|
|
|
|
```js
|
|
|
|
function reverseString(str) {
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
reverseString("hello");
|
|
|
|
```
|
|
|
|
|
|
|
|
# --solutions--
|
|
|
|
|
|
|
|
```js
|
|
|
|
function reverseString(str) {
|
|
|
|
return str.split('').reverse().join('');
|
|
|
|
}
|
|
|
|
|
|
|
|
reverseString("hello");
|
|
|
|
```
|