Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (13.1k points)
Can anyone help me how I can able to reverse a string without using any in-built functions in JavaScript?

1 Answer

0 votes
by (26.7k points)

Basically, there are two methods to do it:

String.prototype.reverse_string=function() {return this.split("").reverse().join("");}

Or,

String.prototype.reverse_string = function() {

    var string = "";

    var i = this.length;

    while (i>0) {

        string += this.substring(i-1,i);

        i--;

    }

    return string;

}

I hope this will help.

Want to become a Java expert? join Java Certification now!!

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Feb 10, 2021 in Java by dante07 (13.1k points)
0 votes
1 answer
0 votes
0 answers

Browse Categories

...