Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

convert english number to bangla in javascript

var finalEnglishToBanglaNumber = {
   0: "০",
   1: "১",
   2: "২",
   3: "৩",
   4: "৪",
   5: "৫",
   6: "৬",
   7: "৭",
   8: "৮",
   9: "৯",
};

String.prototype.getDigitBanglaFromEnglish = function () {
   var retStr = this;
   for (var x in finalEnglishToBanglaNumber) {
      retStr = retStr.replace(
         new RegExp(x, "g"),
         finalEnglishToBanglaNumber[x]
      );
   }
   return retStr;
};

var english_number = "123456";

var bangla_converted_number = english_number.getDigitBanglaFromEnglish();

//outputs : ১২৩৪৫৬

console.log(bangla_converted_number); //or alert(bangla_converted_number);

// another reference
// https://stackoverflow.com/questions/30629242/javascript-replace-to-english-number
Comment

PREVIOUS NEXT
Code Example
Javascript :: loop through key value pairs js 
Javascript :: round function in jquery 
Javascript :: logout in react js 
Javascript :: how to add attribute in jquery 
Javascript :: react fetch post 
Javascript :: add background image to div using jquery 
Javascript :: javascript update attribute 
Javascript :: how to make directory in javascript 
Javascript :: js update query string 
Javascript :: add bootstrap to react 
Javascript :: get value of selected checkbox jquery 
Javascript :: js get data attribute 
Javascript :: Javascript track mouse pointer 
Javascript :: node downgrade windows 
Javascript :: jquery check if field exist by name 
Javascript :: How to find the max id in an array of objects in JavaScript 
Javascript :: remove tr in table jquery 
Javascript :: npm ERR! code EACCES 
Javascript :: react native transparent color 
Javascript :: jimp get image size 
Javascript :: jquery clear select 2 
Javascript :: javascript how to create an array from 1 to 100 
Javascript :: jquery form serialized data 
Javascript :: hello world program in node js 
Javascript :: scoll a div to bottom in angular 
Javascript :: cypress set viewport 
Javascript :: split array into chunks 
Javascript :: jquery disable enter key submit 
Javascript :: javascript get current date jalali 
Javascript :: Typography material ui import 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =