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 :: getting current date and time in javascript 
Javascript :: promise in forloop 
Javascript :: get offset from timezone javascript 
Javascript :: js conditional object key 
Javascript :: javascript string methods 
Javascript :: createrouter vue history remove Hash 
Javascript :: jquery select2 how to make dont close after select 
Javascript :: which methods do not have the hook equivalents in reactjs 16.8++ 
Javascript :: generate component react 
Javascript :: last element in array 
Javascript :: chartjs line color 
Javascript :: html parser javascript 
Javascript :: Set timeouts to XMLHttpRequests in javascript 
Javascript :: difference between two dates in js 
Javascript :: chrome.tab.onupdated 
Javascript :: react useref 
Javascript :: javascript for...in with Arrays 
Javascript :: js test undefined 
Javascript :: jquery ajax on fail 
Javascript :: how to run bare react-native project 
Javascript :: redirect if not logged in next js 
Javascript :: how to debug jest test vscode 
Javascript :: Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax. 
Javascript :: assign class to element javascript 
Javascript :: remove url from string javascript 
Javascript :: regexp constructor javascript 
Javascript :: how to add js in flask 
Javascript :: redirect react router 
Javascript :: npm registry 
Javascript :: convert string number with commas decimal to number javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =