Answers for "reverse an string"

2

how to reverse a string

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

reverse string

def reverse_string(str):
  return str[::-1]
print(reverse_string("This string is reversed!"))
Posted by: Guest on July-09-2021
-1

reverse a string

let t = s.chars().rev().collect::<String>();
Posted by: Guest on February-22-2021
0

reverse a string

public static String reverse(String orig)
{
    char[] s = orig.toCharArray();
    int n = s.length;
    int halfLength = n / 2;
    for (int i=0; i<halfLength; i++)
    {
        char temp = s[i];
        s[i] = s[n-1-i];
        s[n-1-i] = temp;
    }
    return new String(s);
}
Posted by: Guest on July-23-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language