Created
September 3, 2019 06:49
-
-
Save alaminfirdows/21cdd5b1cca212eeed739bcb4b238086 to your computer and use it in GitHub Desktop.
Convert English number to Bangla in Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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