diff --git a/project/ts/functionality/main.ts b/project/ts/functionality/main.ts index 1299516..2fcfee8 100644 --- a/project/ts/functionality/main.ts +++ b/project/ts/functionality/main.ts @@ -16,6 +16,7 @@ import randomNumber from "./randoms/randomNumber"; import removeDuplicate from "./arrays/removeDuplicate"; import reverseString from "./strings/reverseString"; import reverseNumber from "./numbers/reverseNumber"; +import addCommas from "./numbers/addCommas"; import shuffle from "./arrays/shuffle"; import randomString from "./randoms/randomString"; import randomColor from "./randoms/randomColor"; @@ -36,6 +37,7 @@ import getDays from "./user/getDays"; import getHours from "./user/getHours"; import getMinutes from "./user/getMinutes"; import getSeconds from "./user/getSeconds"; +import getBirthDay from "./user/getBirthDay"; import select from "./dom/select"; const functionality = { @@ -54,6 +56,7 @@ const functionality = { randomElementFrom, randomHex, randomNumber, + addCommas, removeDuplicate, reverseString, reverseNumber, @@ -75,6 +78,7 @@ const functionality = { getHours, getSeconds, getMinutes, + getBirthDay, select, }; diff --git a/project/ts/functionality/numbers/addCommas.ts b/project/ts/functionality/numbers/addCommas.ts new file mode 100644 index 0000000..5f3eb8c --- /dev/null +++ b/project/ts/functionality/numbers/addCommas.ts @@ -0,0 +1,9 @@ +/** + * Returns Number With Commas To Facilitate Reading | e.g 1000000 => 1,000,000 + * + * @param {number} number + * @returns {string} + */ +export default function addCommas(number: number): string { + return number.toString().replace(/\B(? 15 + * + * @param {number} year + * @returns {number} + */ +export default function getBirthDay(year: number): number { + var currentDate = new Date(); + var currentYear = currentDate.getFullYear(); + return currentYear - year; +}