Skip to content

Commit 4f77681

Browse files
author
highflyer910
committed
Reverse a String With Recursion
1 parent e7db8f9 commit 4f77681

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

revereseString1.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//Reverse a String With Recursion
2+
3+
4+
function reverseString(str) {
5+
if (str === "")
6+
return "";
7+
else
8+
return reverseString(str.substr(1)) + str.charAt(0);
9+
}

0 commit comments

Comments
 (0)