Skip to content

Instantly share code, notes, and snippets.

@meirlamdan
Last active February 11, 2024 17:34
Show Gist options
  • Select an option

  • Save meirlamdan/9e399dc48c6e7e72ca7905ee852bf496 to your computer and use it in GitHub Desktop.

Select an option

Save meirlamdan/9e399dc48c6e7e72ca7905ee852bf496 to your computer and use it in GitHub Desktop.
Convert number to Hebrew letters js
//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