Fix the String Reversal Function
EasyChallenge 11 of 20
Fix the String Reversal Function
EasyThis function is supposed to reverse a string, but it doesn't handle certain edge cases correctly. Fix the implementation.
Challenge 11 of 20
30 XP
Community Solutions
StringsArraysBasicJavaScript
Exit ChallengeTest Cases
0/3 passingTest Case #1
Input: reverseString('hello')
Expected: 'olleh'
Run tests to see results
Test Case #2
Input: reverseString('Hello, World!')
Expected: '!dlroW ,olleH'
Run tests to see results
Test Case #3
Input: reverseString('')
Expected: ''
Run tests to see results
solution.js
1
<span class="token keyword">function</span> reverseString(str) {
<span class="token keyword">return</span> str.split(<span <span class="token keyword">class</span>="token number">039</span>;<span <span class="token keyword">class</span>="token number">039</span>;).reverse();
}Console
Run your code to see output here