RE: Write a function to reverse a string without using concatenation

    1.Write a function to reverse a string without using concatenation (Hint : Use
    array operations push pop)
    2 Create a custom MyString object that inherits from a String object (Use
    Prototype) and implements the my reverse implemented above

    admin Kid Asked on December 23, 2015 in Javascript.
    Add Comment
    1 Answers
       <script type="text/javascript">
              
            var str = "I love india";
             String.prototype.revrsString = function() {
                      var cc = str.split("");
                       var kk = [];
                       var ss="";
                       for(i=0; i<cc.length; i++){
                              kk.unshift(cc[i]);
                       }
                        for(i=0; i<kk.length; i++){
                             ss+= kk[i];
                         }
                         console.log(ss);
               };
             str.revrsString();
      </script>
       
      Kid Answered on December 23, 2015.
      Add Comment

      Your Answer

      By posting your answer, you agree to the privacy policy and terms of service.