JavaScript invierta una cadena
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("");
const getReverseString = (text) => {
return text.split("").reverse().join("");
}
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("");
let a = "foo";
// function for reversing a string
function reverseString(str) {
return str.split("").reverse().join("");
}
console.log(a); // "foo"
let b = reverseString(a);
console.log(b); // "oof"