Last active
October 28, 2024 18:17
-
-
Save parham-ab/b546ac18fa393b9aa2c9a17c881ff96a to your computer and use it in GitHub Desktop.
A simple JS function to convert English & Persian digits together
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
const englishToPersian = (n) => n.toString().replace(/\d/g, (d) => "۰۱۲۳۴۵۶۷۸۹"[d]); | |
const persianToEnglish = (n) => | |
n.toString().replace(/[۰-۹]/g, (d) => "۰۱۲۳۴۵۶۷۸۹".indexOf(d)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment