JavaScript membalikkan string
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("");
return str.split("").reverse().join("");
const reverse = str => str.split('').reverse().join('');
reverse('hello world');
// Result: 'dlrow olleh'
function reverseString(str) {
let strList = str.split('');
let reversed = strList.reverse();
return reversed.join('');
}
const reverse = str => [...str].reverse().join``;