Repository: pbiswas101/Mathball (js)

Issue:
Kaprekar Number
### Do the checklist before filing the issue:

- [ ] Is this something you can **debug and fix**?
- [x] Do you have Node.js and all the relevant dev-dependencies installed?
- [ ] Is this a **feature request** that you can add?

###### NOTE: Provide a clear and concise description of the feature that needs to be added! Or if its a bug, then provide the necessary steps to reproduce it.

- *Give your answer below:*

------------

[Function: **M.isKaprekar()**] needs to be added!
For more info:

https://www.geeksforgeeks.org/kaprekar-number/

*M.isKaprekar()* needs to accept a positive integer and all other arguments passed should throw a type error which needs to be handled gracefully! For error handling, you should refer to how other features like M.isArmstrong() is implemented.

Pull request description:
Adding toDegrees(), toRadians(). Issue #37
### Do the checklist before submitting the PR:

- [x] Have you read the guidelines mentioned in **CONTRIBUTING.md**?
- [x] Have you squashed your commits?

**Q**: What version of *Node.js* you've used in the project? (`e.g. Node v10.11.0`)
**A**:v11.6.0

**Q**: Mention the *Issue Number*! (`e.g. Fixed #8`)
**A**:#37

- *Give additional information regarding the PR below:*

------------


Patch:
diff --git a/README.md b/README.md
index 3d288dd..83a12ae 100644
--- a/README.md
+++ b/README.md
@@ -22,13 +22,13 @@ $ npm install mathball --save
 
 ## Features
 
-- **Number Checkers** - [isArmstrong][3] - [isAutomorphic][4] - [isCarmichael][43] - [isDeficient][42] - [isFrugal][48] - [isHarshad][45] - [isKaprekar][23] - [isLucky][24] - [isNeon][5] - [isPalindrome][6] - [isPerfect][27] - [isPrime][7] - [isSmith][26]
+- **Number Checkers** - [isArmstrong][3] - [isAutomorphic][4] - [isCarmichael][43] - [isDeficient][42] - [isFrugal][47] - [isHarshad][45] - [isKaprekar][23] - [isLucky][24] - [isNeon][5] - [isPalindrome][6] - [isPerfect][27] - [isPrime][7] - [isSmith][26]
 
-- **Find nth Number** - [bell][32] - [catalan][22] - [factorial][21] - [nCr][58] - [fibonacci][8] - [magic][9] - [padovan][41] - [smart][25]
+- **Find nth Number** - [bell][32] - [catalan][22] - [factorial][21] - [nCr][48] - [fibonacci][8] - [magic][9] - [padovan][41] - [smart][25]
 
 - **Range of Numbers** - [rangePrime][7] - [rangeFibonacci][8]
 
-- **Mathematical Utilities** - [Complex][57] - [frequency][40] - [gcd][10] - [isEven][11] - [isOdd][12] - [lcm][13] - [length][14] - [max][15] - [min][16] - [modInv][39] - [nCr][58] - [pow][46] - [sort][17] - [sum][18]
+- **Mathematical Utilities** - [Complex][49] - [frequency][40] - [gcd][10] - [isEven][11] - [isOdd][12] - [lcm][13] - [length][14] - [max][15] - [min][16] - [modInv][39] - [nCr][48] - [pow][46] - [sort][17] - [sum][18] - [toDegrees][50] - [toRadians][51]
 
 - **Data Structures** - [priorityQueue][44]
 
@@ -112,6 +112,8 @@ The MIT License 2019 - [Priyabrata Biswas][20].
 [44]: https://github.com/pbiswas101/Mathball/blob/master/src/PriorityQueue/index.js
 [45]: https://github.com/pbiswas101/Mathball/blob/master/src/harshad/index.js
 [46]: https://github.com/pbiswas101/Mathball/blob/master/src/pow/index.js
-[48]: https://github.com/pbiswas101/Mathball/blob/master/src/isFrugal/index.js
-[57]: https://github.com/pbiswas101/Mathball/blob/master/src/complex/index.js
-[58]: https://github.com/pbiswas101/Mathball/blob/master/src/nCr/index.js
+[47]: https://github.com/pbiswas101/Mathball/blob/master/src/isFrugal/index.js
+[48]: https://github.com/pbiswas101/Mathball/blob/master/src/nCr/index.js
+[49]: https://github.com/pbiswas101/Mathball/blob/master/src/complex/index.js
+[50]: https://github.com/pbiswas101/Mathball/blob/master/src/degree/index.js
+[51]: https://github.com/pbiswas101/Mathball/blob/master/src/radian/index.js
\ No newline at end of file
diff --git a/src/degree/index.js b/src/degree/index.js
new file mode 100644
index 0000000..9f91797
--- /dev/null
+++ b/src/degree/index.js
@@ -0,0 +1,12 @@
+/*
+    Convery radians to degrees
+    Function: toDegrees()
+*/
+
+const validate = require("../validation/number");
+
+exports.toDegrees = num => {
+
+    validate(num, "toDegrees");
+    return num*180/Math.PI;
+};
\ No newline at end of file
diff --git a/src/index.js b/src/index.js
index 332efe5..04e9803 100644
--- a/src/index.js
+++ b/src/index.js
@@ -36,6 +36,8 @@ const frequency = require('./frequency'),
 	pow = require('./pow'),
 	sort = require('./sort'),
 	sum = require('./sum'),
+	toDegrees = require('./degree'),
+	toRadians = require('./radian'),
 	Complex = require('./complex');
 
 /* Helper Methods */
@@ -79,6 +81,8 @@ module.exports = {
 	isSmith: smith.isSmith,
 	sort,
 	sum,
+	toDegrees: toDegrees.toDegrees,
+	toRadians: toString.toRadians,
 	modInv: modInv.modInv,
 	frequency,
 	isDeficient,
diff --git a/src/radian/index.js b/src/radian/index.js
new file mode 100644
index 0000000..2460d13
--- /dev/null
+++ b/src/radian/index.js
@@ -0,0 +1,12 @@
+/*
+    Convery degrees to radians
+    Function: toRadians()
+*/
+
+const validate = require("../validation/number");
+
+exports.toRadians = num => {
+
+    validate(num, "toRadians");
+    return num*Math.PI/180;
+};


Test patch:
diff --git a/test/degree-spec.js b/test/degree-spec.js
new file mode 100644
index 0000000..019d1ee
--- /dev/null
+++ b/test/degree-spec.js
@@ -0,0 +1,29 @@
+const assert = require('assert'),
+        toDegrees = require("../src/degree").toDegrees;
+
+describe("Function: toDegrees", () => {
+
+    it("should be a function", () => {
+		assert.strictEqual(typeof toDegrees, "function");
+    });
+    
+    it("should throw an error when a string is passed", () => {
+		assert.throws(() => toDegrees("31"), TypeError);
+    });
+    
+    it("should throw an error when a boolean is passed", () => {
+		assert.throws(() => toDegrees(true), TypeError);
+    });
+    
+    it("should return a number", () => {
+		assert.strictEqual(typeof toDegrees(5), "number");
+    });
+
+    it("should return '180' when '3.141592653589793' is passed", () => {
+		assert.strictEqual(toDegrees(Math.PI), 180);
+    });
+    
+    it("should return '75.00017538262475' when '1.309' is passed", () => {
+      assert.strictEqual(toDegrees(1.309), 75.00017538262475);
+    });
+});
\ No newline at end of file
diff --git a/test/radian-spec.js b/test/radian-spec.js
new file mode 100644
index 0000000..789afb5
--- /dev/null
+++ b/test/radian-spec.js
@@ -0,0 +1,29 @@
+const assert = require('assert'),
+        toRadians = require("../src/radian").toRadians;
+
+describe("Function: toRadians", () => {
+
+    it("should be a function", () => {
+		assert.strictEqual(typeof toRadians, "function");
+    });
+    
+    it("should throw an error when a string is passed", () => {
+		assert.throws(() => toRadians("31"), TypeError);
+    });
+    
+    it("should throw an error when a boolean is passed", () => {
+		assert.throws(() => toRadians(true), TypeError);
+    });
+    
+    it("should return a number", () => {
+		assert.strictEqual(typeof toRadians(5), "number");
+    });
+
+    it("should return '3.141592653589793' when '180' is passed", () => {
+		assert.strictEqual(toRadians(180), Math.PI);
+    });
+    
+    it("should return '1.3089999999999997' when '75.00017538262475' is passed", () => {
+      assert.strictEqual(toRadians(75.00017538262475), 1.3089999999999997);
+    });
+});