Skip to content

Instantly share code, notes, and snippets.

@alaminfirdows
Created September 3, 2019 06:49
Show Gist options
  • Save alaminfirdows/21cdd5b1cca212eeed739bcb4b238086 to your computer and use it in GitHub Desktop.
Save alaminfirdows/21cdd5b1cca212eeed739bcb4b238086 to your computer and use it in GitHub Desktop.
Convert English number to Bangla in Javascript
var bnNumbers = {
'0': '০',
'1': '১',
'2': '২',
'3': '৩',
'4': '৪',
'5': '৫',
'6': '৬',
'7': '৭',
'8': '৮',
'9': '৯'
};
String.prototype.getBnDigit = function () {
var str = this;
for (var x in bnNumbers) {
str = str.replace(new RegExp(x, 'g'), bnNumbers[x]);
}
return str;
};
var enNumber = "1234";
console.log(enNumber.getBnDigit());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment