JavaScript Odwróć ciąg
function reverseString(s){
return s.split("").reverse().join("");
}
reverseString("Hello");//"olleH"
Grepper
function reverseString(s){
return s.split("").reverse().join("");
}
reverseString("Hello");//"olleH"
//more compact way:
"my example text".split("").reverse().join("");
"this is a test string".split("").reverse().join("");
//"gnirts tset a si siht"
//as a function
function reverseString(string){
return string.split("").reverse().join("");}
reverseString("test string");
//"gnirts tset"
function reverseString(s){
return s.split("").reverse().join("");
}
reverseString("Hello");//"olleH"
const reverse = str => str.split("").reverse().join("")
function stringReverse(string){
var str = ''
for(const letter of string){
str = letter + str;
}
return str;
}
console.log(stringReverse("Hello World"));
//Output will be
//dlroW olleH