Function convertToWords

  • Converts a number to words in Bangla or English.

    Parameters

    • number: string | number

      The number to convert (can be a number or string).

    • inEnglish: boolean = false

      If true, converts the number to English words. Default is false (converts to Bangla words).

    Returns string

    The number in words.

    If the input is not a valid number or number string.

    convertToWords(123); // "একশত তেইশ"
    convertToWords("123"); // "একশত তেইশ"
    convertToWords("১২৩", true); // "one hundred twenty-three"
    convertToWords(123.45); // "একশত তেইশ দশমিক চার পাঁচ"
    convertToWords("১২৩.৪৫", true); // "one hundred twenty-three point four five"
    convertToWords("০"); // "শূন্য"
    convertToWords(1000000); // "দশ লক্ষ"