Files

64 lines
1.0 KiB
Markdown
Raw Permalink Normal View History

---
id: a202eed8fc186c8434cb6d61
title: Inverter uma string
challengeType: 5
forumTopicId: 16043
dashedName: reverse-a-string
---
# --description--
2021-07-09 21:23:54 -07:00
Inverta a string fornecida.
Você pode ter que transformar a string em um array antes de poder inverter.
2021-07-09 21:23:54 -07:00
Seu resultado deve ser uma string.
# --hints--
2021-07-09 21:23:54 -07:00
`reverseString("hello")` deve retornar uma string.
```js
assert(typeof reverseString('hello') === 'string');
```
2021-07-09 21:23:54 -07:00
`reverseString("hello")` deve retornar a string `olleh`.
```js
assert(reverseString('hello') === 'olleh');
```
2021-07-09 21:23:54 -07:00
`reverseString("Howdy")` deve retornar a string `ydwoH`.
```js
assert(reverseString('Howdy') === 'ydwoH');
```
2021-07-09 21:23:54 -07:00
`reverseString("Greetings from Earth")` deve retornar a string `htraE morf sgniteerG`.
```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");
```