Last active
February 11, 2024 17:34
-
-
Save meirlamdan/9e399dc48c6e7e72ca7905ee852bf496 to your computer and use it in GitHub Desktop.
Convert number to Hebrew letters js
This file contains hidden or 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
| //https://stackoverflow.com/a/30676253/12782960 in c# | |
| function formatHebrew(num) { | |
| if(num <= 0) return | |
| let ret = 'ת'.repeat(Math.floor(num / 400)); | |
| num %= 400; | |
| if(num >= 100) { | |
| ret += "קרש"[Math.floor(num / 100) - 1]; | |
| num %= 100; | |
| } | |
| switch(num) { | |
| // Avoid letter combinations from the Tetragrammaton | |
| case 16: | |
| ret += "טז"; | |
| break; | |
| case 15: | |
| ret += "טו"; | |
| break; | |
| default: | |
| if (num >= 10) { | |
| ret += "כלמנסעפצי"[Math.floor(num / 10) - 1]; | |
| num %= 10; | |
| } | |
| if(num > 0) { | |
| ret += "אבגדהוזחט"[num - 1]; | |
| } | |
| break; | |
| } | |
| return ret; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment