function separatedPrice(price) { if (price) { return String(price).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); } return price; }