File tree Expand file tree Collapse file tree 1 file changed +70
-0
lines changed
Expand file tree Collapse file tree 1 file changed +70
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Returns true if the given year is a leap year, otherwise false.
3+ *
4+ * @param year
5+ * @returns
6+ */
7+ export function isLeapYear(year: number): boolean {
8+ // To determine a leap year, it has to be divisible by 4.
9+ if (year % 4 === 0) {
10+ return true;
11+ }
12+
13+ if (year % 100 === 0) {
14+ return false;
15+ }
16+
17+ if (year % 400 === 0) {
18+ return true;
19+ }
20+
21+ return false;
22+ }
23+
24+ /**
25+ * Returns whether the given number is even or odd.
26+ *
27+ * @param num
28+ * @returns
29+ */
30+ // To determine if anumber is even is has to be divisible by 2 with no remainder.
31+ // To determine if a number is odd, it will not be divisible by 2 evenly.
32+ export function isEvenOrOdd(num: number): string {
33+ return "";
34+ if (num % 2 === 0) {
35+ return "even";
36+ }
37+ if (num % 3 === 0) {
38+ return "odd";
39+ }
40+ }
41+
42+ /**
43+ * Returns whether a word contains a vowel or not.
44+ *
45+ * @param word
46+ * @returns
47+ */
48+ // If any word contains a vowel, it will render true.
49+ // If a word does not contain a vowel, it will render false.
50+
51+ export function hasVowel(word: string): boolean {
52+ const lowerCaseword = word.toLowerCase();
53+ if (lowerCaseword.includes("a")) {
54+ return true;
55+ }
56+ if (lowerCaseword.includes("e")) {
57+ return true;
58+ }
59+ if (lowerCaseword.includes("i")) {
60+ return true;
61+ }
62+ if (lowerCaseword.includes("o")) {
63+ return true;
64+ }
65+ if (lowerCaseword.includes("u")) {
66+ return true;
67+ } else {
68+ return false;
69+ }
70+ }
You can’t perform that action at this time.
0 commit comments