UNPKG

nth-root

Version:
64 lines (44 loc) 1.12 kB
# nth-root [![NPM version](https://badge.fury.io/js/nth-root.svg)](http://badge.fury.io/js/nth-root) > Get the nth root of a number. ## Install with [npm](npmjs.org) ```bash npm i nth-root --save ``` ## Usage ```js var nthRoot = require('nth-root'); ``` Returns the square root of the given number by default: ```js nthRoot(16); //=> '4' nthRoot(-16); //=> '-4' ``` Pass a degree as the second param. e.g. to get cube root: ```js nthRoot(-27, 3); //=> '-3' nthRoot(27, 3); //=> '3' nthRoot(-8, 3); //=> '-2' nthRoot(8, 3); //=> '2' ``` ## Run tests Install dev dependencies: ```bash node i -d && mocha ``` ## Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/nth-root/issues) ## Author **Jon Schlinkert** + [github/jonschlinkert](https://github.com/jonschlinkert) + [twitter/jonschlinkert](http://twitter.com/jonschlinkert) ## License Copyright (c) 2015 Jon Schlinkert Released under the MIT license *** _This file was generated by [verb](https://github.com/assemble/verb) on January 18, 2015._