Answer the question
In order to leave comments, you need to log in
How to format number in js and output in pug?
Good day to all.
I pass in the object
offers
{
"id":129,
"logourl":"129.png",
"mincreditsum":7000,
"maxcreditsum":200000"
}
I want to format mincreditsum and maxcreditsum and bring them to the form 7,000 and 200,000.
I found such a regular
expression. Now I output it in a loop like thisreplace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ')
each offer,index in offers_arr
span.minsumm !{offer.mincreditsum}
span.maxsumm !{offer.maxcreditsum}
script.
var myFunc = function (a) {
return a.replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ');
}
each offer,index in offers_arr
span#summin!= myFunc(offer.mincreditsum)
Call to undefined function myFunc()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question