Give help. Get help.

  • # June 25, 2014 at 4:01 am

    Hi folks,

    I’m trying to reverse a string using a method of a function, I keep getting undefined in the console, can anyone please help?

    function MyString(string) {
        for (var i=0;i<string.length;i++) {
        this.reverseit = reverseit;
        function reverseit(string){
          for (var i = string.length - 1; i >= 0; i--){
    var s=new MyString('hello');
    # June 25, 2014 at 5:01 am

    It is difficult to see how you got to this code. What is this referring to in both of the for loops?

    For reversing you can use the code at but please read about the caveats of character encoding on the same page.

    You also might want to store the string used in your constructor to be reused in your reversed code.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.