appNumber function

String appNumber(
  1. int value
)

For numbers 1-9, return the number spelled out. Otherwise, return the number. This follows Associated Press style.

Implementation

String appNumber(int value) {

  List values = [
    "one",
    "two",
    "three",
    "four",
    "five",
    "six",
    "seven",
    "eight",
    "nine"
  ];

  if (value < 0 || value > 10) {
    return "$value";
  }else{
      return values[value-1];
  }
}