1function reverseString(s){
2 return s.split("").reverse().join("");
3}
4reverseString("Hello");//"olleH"
1"this is a test string".split("").reverse().join("");
2//"gnirts tset a si siht"
3
4// Or
5const reverse = str => [...str].reverse().join('');
6
7// Or
8const reverse = str => str.split('').reduce((rev, char)=> `${char}${rev}`, '');
9
10// Or
11const reverse = str => (str === '') ? '' : `${reverse(str.substr(1))}${str.charAt(0)}`;
12
13// Example
14reverse('hello world'); // 'dlrow olleh'
1const reverse = str => str.split('').reverse().join('');
2
3reverse('hello world');
4// Result: 'dlrow olleh'
5