JavaScript umgekehrt eine Zeichenfolge umgekehrt
function reverseString(s){
return s.split("").reverse().join("");
}
reverseString("Hello");//"olleH"
Grepper
function reverseString(s){
return s.split("").reverse().join("");
}
reverseString("Hello");//"olleH"
'hello world'[::-1]
'dlrow olleh'
const reverse = str => str.split('').reverse().join('');
reverse('hello world');
// Result: 'dlrow olleh'
const stringReverse = str => str.split("").reverse().join("");
stringReverse("Welcome to Javascript")
//tpircsavaJ ot emocleW
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);
}
static string reverseString(string str){
string output = "";
int length = str.Length-1;
for (int i = 0; i < length+1; i++)
{
output += str[length - i];
}
return output;
}