Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

format amount in javascript

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

PREVIOUS NEXT
Code Example
Javascript :: 1 line unique id 
Javascript :: angular pipe for 2 decimal places 
Javascript :: call a function on load jquery 
Javascript :: click to copy react 
Javascript :: how to displayan inteiger to a tenth in javascript 
Javascript :: remove header from certain pages react navigation 
Javascript :: js replace single quote with doubel quote 
Javascript :: javascript remove line breaks from string 
Javascript :: Javascript get random item from array 
Javascript :: box shadow react native 
Javascript :: jest wait for x seconds 
Javascript :: create-react-app 
Javascript :: axios node js set user agent 
Javascript :: read directory in node js 
Javascript :: javascript get element width 
Javascript :: date add 1 hour javascript 
Javascript :: alphabets regex js javascript 
Javascript :: how to set by jasmine.DEFAULT_TIMEOUT_INTERVAL 
Javascript :: giving height full in next image 
Javascript :: math.random javascript 
Javascript :: javascript get current time 
Javascript :: get header height jquery 
Javascript :: js call function onload 
Javascript :: js for each character in string 
Javascript :: send a file ajax 
Javascript :: js get number of keys in object 
Javascript :: discord.js cooldown 
Javascript :: bootstrap not working in angular 
Javascript :: local storage javascript array 
Javascript :: react get route path 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =