How do you reverse a string in place in JavaScript?

前端 未结 30 2360
猫巷女王i
猫巷女王i 2020-11-22 00:29

How do you reverse a string in place (or in-place) in JavaScript when it is passed to a function with a return statement, without using built-in functions (.reverse()<

30条回答
  •  不知归路
    2020-11-22 00:37

    var str = "my name is saurabh ";
    var empStr='',finalString='';
    var chunk=[];
    function reverse(str){
    var i,j=0,n=str.length;
        for(i=0;i=0;z--){
            finalString = finalString +' '+ chunk[z];
            console.log(finalString);
        }
        return true;
    }
    reverse(str);
    

提交回复
热议问题