Created
January 7, 2019 22:51
-
-
Save kevinahn7/12661be2df8bc94036183d60922d9602 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function makeToString(integer) { | |
| let string = ""; | |
| let numbers = { | |
| 0: "0", | |
| 1: "1", | |
| 2: "2", | |
| 3: "3", | |
| 4: "4", | |
| 5: "5", | |
| 6: "6", | |
| 7: "7", | |
| 8: "8", | |
| 9: "9", | |
| } | |
| let neg = ""; | |
| if (integer < 0) { | |
| neg = "-"; | |
| integer = integer * -1; | |
| } | |
| let theInteger = integer; | |
| while (theInteger > 0) { | |
| let inputNumber = theInteger % 10; | |
| string = numbers[inputNumber] + string; | |
| theInteger = Math.floor(theInteger / 10); | |
| } | |
| return neg + string; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment