Skip to content

Commit 0d6b4f7

Browse files
committed
feat: completed lesson_07/hw #b
1 parent fc17b48 commit 0d6b4f7

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

lesson_07/conditionals/Chutt_lesson07

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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+
}

0 commit comments

Comments
 (0)