1function reverseString(s){
2 return s.split("").reverse().join("");
3}
4reverseString("Hello");//"olleH"
1function reverseString(str) {
2
3 var newString = "";
4
5 for (var i = str.length - 1; i >= 0; i--) {
6 newString += str[i];
7
8 return newString;
9}
10
11reverseString('hello');
1str.split('').reduce((reversed, character) =>{
2 return character + reversed;
3 }, '');
4//apple = leppa
1var s = userInput[0];
2var rev = [];
3for(let i=0;i<s.length;i++)
4{
5 rev.push(s[s.length-1-i]);
6}
7console.log(rev.join(""));
1function spinWords(pw){
2 let a = pw.split(" ")
3 let variavel = ''
4 console.log('1º Problema da Vida Real')
5 for (var i = 0; i < a.length; i++) {
6 if(a[i].length <= 5){
7 variavel += a[i].split("").reverse().join().replaceAll("," , "") + " "
8 }
9 else {
10 variavel += a[i] + " "
11 }
12 }
13 return variavel
14}
15
16let hey = "hello worlds";
17console.log(spinWords(hey)) // olleh worlds