Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript format currency

function formatToCurrency(amount){
    return (amount).toFixed(2).replace(/d(?=(d{3})+.)/g, '$&,'); 
}
formatToCurrency(12.34546); //"12.35"
formatToCurrency(42345255.356); //"42,345,255.36"
Comment

javascript format number as currency

const formatter = new Intl.NumberFormat('en-US', {
  style: 'currency',
  currency: 'USD',
  minimumFractionDigits: 2
})

formatter.format(1000) // "$1,000.00"
formatter.format(10) // "$10.00"
formatter.format(123233000) // "$123,233,000.00"
Comment

javascript rupiah currency format

const rupiah = (number) => {
	return new Intl.NumberFormat("id-ID", {
		style: "currency",
		currency: "IDR"
	}).format(number);
}
Comment

javascript currency format

const formatter = new Intl.NumberFormat('en-ID', {
  style: 'currency',
  currency: 'IDR'
}).format(10000000)
.replace(/[IDR]/gi, '')
.replace(/(.+d{2})/, '')
.trimLeft()


console.log(`Rp ${formatter}`)
Comment

javascript number format indian currency

(1234567.8).toFixed(2).replace(/(d)(?=(d{2})+d.)/g, '$1,') // "12,34,567.80"
Comment

Javascript number format, currency format

const yourNumber = -100
const nf = new Intl.NumberFormat('en-GB', { style: 'currency', currency: 'GBP' })
console.log(nf.format(yourNumber))
 Run code snippet
Comment

PREVIOUS NEXT
Code Example
Javascript :: js associative array push 
Javascript :: How to get the background image URL of an element using jQuery 
Javascript :: call json api javascript 
Javascript :: how to convert seconds in hours minutes and seconds js 
Javascript :: how to find duplicate values in an array javascript 
Javascript :: short string javascript 
Javascript :: replace each string by another string javascript 
Javascript :: js find all max number indexes in array 
Javascript :: how to get variable value outside function in javascript 
Javascript :: •“In React, everything is a component.” Explain 
Javascript :: js if else statement one line 
Javascript :: what is jquery 
Javascript :: hcaptcha bypass 
Javascript :: Quick Git Setup 
Javascript :: react build command 
Javascript :: import svg as react component 
Javascript :: react-native build debug apk 
Javascript :: react native navigation remove top header screen 
Javascript :: Use parseInt() in the convertToInteger function so it converts a binary number to an integer and returns it. 
Javascript :: disable VirtualizedLists should never be nested inside 
Javascript :: regex e-mail 
Javascript :: js day monday tuesday wednesday 
Javascript :: how to insert an item into an array at a specific index in javascript 
Javascript :: atob javascript 
Javascript :: how to write a json in r 
Javascript :: jquery console log 
Javascript :: js queryselector find without attribute 
Javascript :: jquery onclick anchor tag scroll to div with exact position 
Javascript :: change a variable outside a function js 
Javascript :: state hook is not updating react 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =