Home > database >  How can we write any currency symbol in visual studio?
How can we write any currency symbol in visual studio?

Time:08-06

I am working on a WebApp using React and have to use various currency symbols but dollar symbol is provided to us in keyboard only. So, how could i use differnt currency sysmbols? Is there some solution common to all platforms or specific one for VS code?

CodePudding user response:

You need to install this library

currency-symbol

Example

//ES5
const currencySymbol = require('currency-symbol');
 
// ES6
import currencySymbol from 'currency-symbol';
 
console.log(currencySymbol.all());
// This will return all curriencies symbol
 
console.log(currencySymbol.symbol("United States")); //$
// This will return '$' which is $.
 
console.log(currencySymbol.symbol("USD")); //$
// This will return '$' which is $.
 
console.log(currencySymbol.symbol("Dollar")); //$
// This will return '$' which is $.
 
console.log(currencySymbol.symbol("Nigeria")); //₦
// This will return '₦' which is ₦.
 
console.log(currencySymbol.symbol("NGN")); //₦
// This will return '₦' which is ₦.
 
console.log(currencySymbol.symbol("Naira")); //₦
// This will return '₦' which is ₦.
 
console.log(currencySymbol.symbol("GHC")); //¢
// This will return '¢' which is ¢
 
console.log(currencySymbol.symbol("Ghana")); //¢
// This will also return '¢' which is ¢
 
console.log(currencySymbol.symbol("Cedis")); //¢
// This will also return '¢' which is ¢.
 
/***
* Note: the .symbol() function takes any of this arguments - Country Name, Currency Name and Currency Abbreviation and return the currency symbol.
***/

You need to use above library or use code like this for related currency like this $ for dollar

  • Related