Skip to content

Isometric line figures that answer the pointer. For React and for anything with a DOM.

653 B
Raw Blame
const ONES = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"];
const TENS = ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"];

/** A count as the site's prose writes it, "twenty-one", so a sentence is read from a list and cannot fall behind it. Up to 99. */
export function spell(n: number): string {
  if (n < 20) return ONES[n];
  return TENS[Math.floor(n / 10)] + (n % 10 ? `-${ONES[n % 10]}` : "");
}

export const cap = (s: string) => s[0].toUpperCase() + s.slice(1);