jQuery add spaces to prices

CoderHomie answered on May 17, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers


jQuery add spaces to prices

0

// For integers use

function numberWithSpaces(x) {

return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");

}

// For floating point numbers you can use

function numberWithSpaces(x) {

var parts = x.toString().split(".");

parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, " ");

return parts.join(".");

 

Popularity 1/10 Helpfulness 1/10 Language javascript
Source: Grepper
Link to this answer
Share Copy Link
Contributed on May 17 2023
CoderHomie
0 Answers  Avg Quality 2/10


X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.