Skip to content

Instantly share code, notes, and snippets.

View heymexa's full-sized avatar

Mikhail Voronov heymexa

  • Krasnodar, Russia
View GitHub Profile
/**
* @param {number} sum
* @returns {string}
* @example
* 1234567 -> 1 234 567
*/
function formatNumber (number) {
return number.toString().replace(/(\d)(?=(\d{3})+([\D]|$))/g, '$1 ');
}