The following is a quick JavaScript function which will return the reverse of a string:
String.prototype.reverse = function() {
return this.split("").reverse().join("");
};
The above function is a function that, once defined, will exist for every string. Here are some examples of how to use the above function:
alert("Hello world!!!".reverse()); // !!!dlrow olleH
alert("rise to vote sir".reverse()); // ris etov ot esir
alert("smart trams".reverse()); // smart trams
By the way, if you noticed the last two examples and are trying to think of the word for those types of phrases, it is palindrome. 8)