Skip to content

Instantly share code, notes, and snippets.

@Burick
Created May 24, 2016 12:16
Show Gist options
  • Save Burick/b5556f6a312bd3537dead8a06bcc85ba to your computer and use it in GitHub Desktop.
Save Burick/b5556f6a312bd3537dead8a06bcc85ba to your computer and use it in GitHub Desktop.
Форматирование цены Js
/*
layerPrice цена которую нужно отформатировать
formattedPrice отформатировананя цена
*/
var roundedPrice = Math.round(layerPrice)
var formattedPrice = (roundedPrice + "").replace(/(\d)(?=(\d\d\d)+$)/, "$1 ")
@Burick
Copy link
Author

Burick commented May 24, 2016

(product.html().replace(/\s/g, '')*2).toString().split('').reverse().join('').replace(/([0-9]{3})/g, "$1 ").split('').reverse().join('')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment