Add a reverse method to the String 'class' so that every instance of String can call reverse and reverse itself. - Node.js String

Node.js examples for String:Algorithm

Description

Add a reverse method to the String 'class' so that every instance of String can call reverse and reverse itself.

Demo Code


//code here/*from ww w  .j a v a 2 s.c o  m*/
String.prototype.reverse = function(string){
    var temp = string.split('').reverse().join('');
    return temp;
}

Related Tutorials