💥Conversion Functions
A set of functions can be utilized to convert numbers between their Arabic text representation and their numerical form.
Table of Contents
text2number
Syntax
text2number(text)Description
Converts a given Arabic text representation of a number into its numerical form. The input text should be a string containing Arabic words representing a number.
Parameters
text(string) - The input Arabic text representing a number.
Returns
number- The numerical form of the given Arabic text.
Example
const text = "خمسة عشر";
const number = text2number(text);
console.log(number); // 15number2text
Syntax
Description
Converts a given number into its Arabic text representation. The input can be a number or a string containing a number.
Parameters
anumber(number | string) - The input number or a string containing a number.
Returns
string- The Arabic text representation of the given number.
Example
number2ordinal
Syntax
Description
Converts a given number to its Arabic ordinal form.
Parameters
anumber(number|string): The input number to be converted to its ordinal form.feminin(boolean, optional, default=false): If true, the output ordinal will be in the feminine form.
Returns
ordinalString(string): The Arabic ordinal string representation of the input number.
Example
Last updated