2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
id: a202eed8fc186c8434cb6d61
|
|
|
|
title: Reverse a String
|
|
|
|
isRequired: true
|
|
|
|
challengeType: 5
|
|
|
|
videoUrl: ''
|
|
|
|
localeTitle: 反转字符串
|
|
|
|
---
|
|
|
|
|
|
|
|
## Description
|
2020-06-30 01:51:26 -07:00
|
|
|
<section id="description">反转提供的字符串。您可能需要先将字符串转换为数组,然后才能将其反转。您的结果必须是字符串。如果卡住,请记得使用<a href="https://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck-coding/19514" target="_blank">Read-Search-Ask</a> 。编写自己的代码。 </section>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
## Instructions
|
|
|
|
<section id="instructions">
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
```yml
|
|
|
|
tests:
|
|
|
|
- text: <code>reverseString("hello")</code>应该返回一个字符串。
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert(typeof reverseString("hello") === "string");
|
2018-10-10 18:03:03 -04:00
|
|
|
- text: <code>reverseString("hello")</code>应该变成<code>"olleh"</code> 。
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert(reverseString("hello") === "olleh");
|
2018-10-10 18:03:03 -04:00
|
|
|
- text: <code>reverseString("Howdy")</code>应该变成<code>"ydwoH"</code> 。
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert(reverseString("Howdy") === "ydwoH");
|
2018-10-10 18:03:03 -04:00
|
|
|
- text: <code>reverseString("Greetings from Earth")</code>应返回<code>"htraE morf sgniteerG"</code> 。
|
2020-02-18 01:40:55 +09:00
|
|
|
testString: assert(reverseString("Greetings from Earth") === "htraE morf sgniteerG");
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
<div id='js-seed'>
|
|
|
|
|
|
|
|
```js
|
|
|
|
function reverseString(str) {
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
reverseString("hello");
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
|
|
```js
|
|
|
|
// solution required
|
|
|
|
```
|
2020-08-13 17:24:35 +02:00
|
|
|
|
|
|
|
/section>
|