Javascript Regex: replacing the last dot for a comma

前端 未结 5 983
情歌与酒
情歌与酒 2021-01-05 20:38

I have the following code:

var x = \"100.007\"
x = String(parseFloat(x).toFixed(2));
return x
=> 100.01

This works awesomely just how I

5条回答
  •  不知归路
    2021-01-05 21:39

    You don't need to worry about whether or not it's the last ".", because there is only one. JavaScript doesn't store numbers internally with comma or dot-delimited sets.

提交回复
热议问题