Skip to content

Instantly share code, notes, and snippets.

View davodaslanifakor's full-sized avatar
🔬
Work at office

Davod Aslani Fakor davodaslanifakor

🔬
Work at office
View GitHub Profile
@davodaslanifakor
davodaslanifakor / rial-to-toman.js
Last active January 25, 2020 13:14
convert rial to persian letters toman
// include https://github.com/mahmoud-eskandari/NumToPersian
get_persian(val) {
// return "صفر تومان" if val is 0
if(Number(val) === 0) return 'صفر تومان';
// check value for change separated value to number
let non_separated_val = isNaN(val) ? Number(val.split(',').join('')) :val;
// get "toman" part if number is bigger than 9 rial
let toman_part = non_separated_val > 9 ? Num2persian(Math.floor(non_separated_val / 10)) + ' تومان ' : '';