--- id: a202eed8fc186c8434cb6d61 title: Reverse a String isRequired: true challengeType: 5 videoUrl: '' localeTitle: 反转字符串 --- ## Description <section id="description">反转提供的字符串。您可能需要先将字符串转换为数组,然后才能将其反转。您的结果必须是字符串。如果卡住,请记得使用<a href="https://www.freecodecamp.org/forum/t/how-to-get-help-when-you-are-stuck-coding/19514" target="_blank">Read-Search-Ask</a> 。编写自己的代码。 </section> ## Instructions <section id="instructions"> </section> ## Tests <section id='tests'> ```yml tests: - text: <code>reverseString("hello")</code>应该返回一个字符串。 testString: assert(typeof reverseString("hello") === "string"); - text: <code>reverseString("hello")</code>应该变成<code>"olleh"</code> 。 testString: assert(reverseString("hello") === "olleh"); - text: <code>reverseString("Howdy")</code>应该变成<code>"ydwoH"</code> 。 testString: assert(reverseString("Howdy") === "ydwoH"); - text: <code>reverseString("Greetings from Earth")</code>应返回<code>"htraE morf sgniteerG"</code> 。 testString: assert(reverseString("Greetings from Earth") === "htraE morf sgniteerG"); ``` </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 ``` </section>