Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save kevinahn7/12661be2df8bc94036183d60922d9602 to your computer and use it in GitHub Desktop.

Select an option

Save kevinahn7/12661be2df8bc94036183d60922d9602 to your computer and use it in GitHub Desktop.
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