JavaScript Program to Format Numbers as Currency Strings Using toLocaleString() Method Full Project For Beginners

 

 

script.js

 

 

// program to format numbers as currency string
const formatter = new Intl.NumberFormat('en-US', {
    style: 'currency',
    currency: 'USD'
});

formatter.format(2500);

 

 

// program to format numbers as currency string

const result =  (2500).toLocaleString('en-US', {
    style: 'currency',
    currency: 'USD'
});

console.log(result);

Leave a Reply