javaScript обратите за собой строку
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 reverse(str){
let reversed = "";
for (var i = str.length - 1; i >= 0; i--){
reversed += str[i];
}
return reversed;
}
//Reverse the Case
function reverseCase(str) {
return str.replace(/./g, c => c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase());
}
console.log(reverseCase("Happy Birthday")); // "hAPPY bIRTHDAY"
console.log(reverseCase("MANY THANKS")); // "many thanks"
console.log(reverseCase("sPoNtAnEoUs")); // "SpOnTaNeOuS"
const reversString = (s="") => s.split().reverse().join();