使用JavaScript将数字转换为印度货币
假设我们有任何数字,并且需要编写一个接受数字并返回其等值印度货币的JavaScript函数。
toCurrency(1000) --> ₹4,000.00 toCurrency(129943) --> ₹1,49,419.00 toCurrency(76768798) --> ₹9,23,41,894.00
示例
为此的代码将是-
const num1 = 1000;
const num2 = 129943;
const num3 = 76768798;
const toIndianCurrency = (num) => {
const curr = num.toLocaleString('en-IN', {
style: 'currency',
currency: 'INR'
});
return curr;
};
console.log(toIndianCurrency(num1));
console.log(toIndianCurrency(num2));
console.log(toIndianCurrency(num3));输出结果
控制台中的输出将是-
₹1,000.00 ₹1,29,943.00 ₹7,67,68,798.00
热门推荐
10 诗词送行祝福语大全简短
11 新房开工吉日祝福语简短
12 50多岁生日简短祝福语
13 安徽疫情祝福语简短英语
14 农民朋友发财祝福语简短
15 对生活祝福语简短精辟
16 搬家词简短祝福语朋友
17 女神结婚快乐祝福语简短
18 文学短句祝福语大全简短