My Code:
I tried the following code but the order of words are changing
var str = \"Welcome to my Website !\";
alert(str.split(\"\").reverse().join(
I just solved this using a functional approach and typescript:
const aString = "Our life always expresses the result of our dominant thoughts.";
function reverseString (str: string) :string {
return str.split('').reverse().join('')
}
function reverseWords(str:string) :string {
return str.split(" ").map(reverseString).join(" ")
}
console.log(reverseWords(aString))
// ruO efil syawla sesserpxe eht tluser fo ruo tnanimod .sthguoht