2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
id: a202eed8fc186c8434cb6d61
|
2020-12-16 00:37:30 -07:00
|
|
|
title: 反转字符串
|
2018-10-10 18:03:03 -04:00
|
|
|
challengeType: 5
|
2021-01-12 08:18:51 -08:00
|
|
|
forumTopicId: 16043
|
2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --description--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2021-01-12 08:18:51 -08:00
|
|
|
请反转传入函数的字符串。
|
|
|
|
|
|
|
|
在反转字符串之前,你可能需要将其切分成包含字符的数组。
|
|
|
|
|
|
|
|
函数的返回结果应为字符串。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --hints--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2021-01-12 08:18:51 -08:00
|
|
|
`reverseString("hello")` 应返回一个字符串。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
```js
|
|
|
|
assert(typeof reverseString('hello') === 'string');
|
2018-10-10 18:03:03 -04:00
|
|
|
```
|
|
|
|
|
2021-01-12 08:18:51 -08:00
|
|
|
`reverseString("hello")` 应返回 `"olleh"`。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
```js
|
2020-12-16 00:37:30 -07:00
|
|
|
assert(reverseString('hello') === 'olleh');
|
2018-10-10 18:03:03 -04:00
|
|
|
```
|
|
|
|
|
2021-01-12 08:18:51 -08:00
|
|
|
`reverseString("Howdy")` 应返回 `"ydwoH"`。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
```js
|
|
|
|
assert(reverseString('Howdy') === 'ydwoH');
|
|
|
|
```
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2021-01-12 08:18:51 -08:00
|
|
|
`reverseString("Greetings from Earth")` 应返回 `"htraE morf sgniteerG"`。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
```js
|
2020-12-16 00:37:30 -07:00
|
|
|
assert(reverseString('Greetings from Earth') === 'htraE morf sgniteerG');
|
2018-10-10 18:03:03 -04:00
|
|
|
```
|
2020-08-13 17:24:35 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --solutions--
|
|
|
|
|