Replace all left spaces with a specific string

前端 未结 5 512
时光说笑
时光说笑 2020-12-19 11:18

I have following code to replace left spaces with a specific string but, It is not working as I want.

5条回答
  •  攒了一身酷
    2020-12-19 11:47

    This will surely do in two lines:

      var str ='   asdadasdad as asdasd asasd';   
      console.log(str.trim().padStart(str.length, 'x')); 
    

提交回复
热议问题