Reverse a String - Enter a string and the program will reverse it and print it out. - Node.js String

Node.js examples for String:Algorithm

Description

Reverse a String - Enter a string and the program will reverse it and print it out.

Demo Code


String.prototype.reverse = function () {
    "use strict";

    var i,/*from   ww  w. ja v  a2 s  . c om*/
        r;

    for (i = this.length - 1, r = ''; i >= 0; r += this[i--]) {}
    return r;
};

this.console.log("stringExample".reverse());

Related Tutorials