Pages

Tuesday, September 20, 2016

Comment carefully

What's wrong with the following snippet?

    function pow(number, exponent) {
      if (exponent < 0) {
        return 1 / pow(number, -1 * exponent);
      }
      else if (exponent == 0) {
        return 1;
      }
      else // exponent > 0 {
        return number * pow(number, exponent - 1);
      }
    }