Well, as this looks like a homework question, I'd expect that they are looking for the naive way of reversing strings, but this only properly works on none unicode strings. If you are looking for a more comprehensive solution, and it wasn't for homework, I'd use
this[
^] library.
So, what is the naive version? It's quite simple really:
var text = 'Text to reverse';
var reversed = text.split('').reverse().join('');
If you want to be really cunning, you could add this to the
String
prototype like this:
String.prototype.reverse = function(){ return this.split('').reverse().join('');}
What this functionality does is split the string into individual characters, then it reverses the order of them and finally it joins them back together again with no space in between.