Answers for "how to reverse function in string"

2

how to reverse a string

function reverseString(str) {
    return str.split("").reverse().join("");
}
reverseString("hello");
Posted by: Guest on May-13-2020
0

reverse a string

String -- Reverse
Write a return method that can reverse  String
Ex: Reverse("ABCD"); ==> DCBA

USING CORE JAVA
public static String StrReverse(String str) {
String reverse="";
for(int i=str.length()-1; i >= 0; i--)
reverse += str.toCharArray()[i];
 
return  reverse;
}
 
USING STRING BUFFER/BUILDER
public static String  Reverse(String str) {
return new StringBuffer(str).reverse().toString();
}
Posted by: Guest on September-29-2021

Code answers related to "how to reverse function in string"

Code answers related to "Javascript"

Browse Popular Code Answers by Language