Skip to content

Instantly share code, notes, and snippets.

View parham-ab's full-sized avatar
💭

Parham Abolghasemi parham-ab

💭
View GitHub Profile
@parham-ab
parham-ab / digitsConvert.js
Last active July 6, 2023 07:20
A simple JS function to convert English & Persian digits together
const englishToPersian = (n) => n.toString().replace(/\d/g, (d) => "۰۱۲۳۴۵۶۷۸۹"[d]);
const persianToEnglish = (n) =>
n.toString().replace(/[۰-۹]/g, (d) => "۰۱۲۳۴۵۶۷۸۹".indexOf(d));