Ad
ES2015
Babel

'Cuase why not :)

Code
Diff
  • /**
     * @param {Number} approximation - number of decimal places you're loojing for. 
     *  Shouldn't exceed 6 as Zu Chongzhi ratio are only valid until first 6 digits.
     *  Is 2 by default.
     */
    const pi = (approximation = 2) =>
      /** Let's use [this guy's](https://en.wikipedia.org/wiki/Zu_Chongzhi) ratio to calc Pi */
      (355 / 113).toFixed(approximation > 2 && approximation <= 6 ? approximation : 2)
    • const pi = () => {
    • }
    • pi()
    • /**
    • * @param {Number} approximation - number of decimal places you're loojing for.
    • * Shouldn't exceed 6 as Zu Chongzhi ratio are only valid until first 6 digits.
    • * Is 2 by default.
    • */
    • const pi = (approximation = 2) =>
    • /** Let's use [this guy's](https://en.wikipedia.org/wiki/Zu_Chongzhi) ratio to calc Pi */
    • (355 / 113).toFixed(approximation > 2 && approximation <= 6 ? approximation : 2)