Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js format string 2 digits

[7, 27.5, -7.2345].forEach(myNumber => {
  let formattedNumber = myNumber.toLocaleString('en-US', {
    minimumIntegerDigits: 2,
    useGrouping: false
  })
  console.log(
    'Input:    ' + myNumber + '
' +
    'Output:   ' + formattedNumber
  )
})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #format #string #digits
ADD COMMENT
Topic
Name
6+9 =