How to reverse a string in javascript without using any inbuild funcition ,meanwhile it can change the original string :    

     function reverse1(str){
      var a = "";
      for(var i = 0; i <= str.length/2; i++){
        a = str[i];
        str[i] = str[str.length-i-1];
        str[str.length-i-1] = a;
      }
      return str;
    }
    var str = "abcdef";
    reverse1(str);
I want to reverse a string without using any inbuild function ,and i want it to change the original string itself but it doesn't work well.
the language is javascript.
