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 October 28, 2024 18:17
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));