checkRange function

int checkRange(
  1. int orig,
  2. int converted
)

Implementation

int checkRange(int orig, int converted) {
  if (orig.isNaN || converted.isNaN || (!(orig is int) && !(orig is String))) {
    throw 'Expected number';
  }
  if (orig != converted) {
    throw 'Number is out of range';
  }
  return orig;
}