javaScript обратите за собой строку
function reverseString(s){
return s.split("").reverse().join("");
}
reverseString("Hello");//"olleH"
Grepper
function reverseString(s){
return s.split("").reverse().join("");
}
reverseString("Hello");//"olleH"
"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;
}
const str = 'JavaScript is awesome';
function reverseAString(str) {
return str.split('').reverse().join('');
}
console.log(`Reversed string is: ${reverseAString(str)}`);
const solution = (str) => str.split("").reverse().join("");
function reverseString(str) {
return str
.split("")
.reverse()
.join("");
}