Skip to content

Commit fc17b48

Browse files
committed
feat: add lesson_07 hw
1 parent a4c4623 commit fc17b48

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

lesson_07/conditionals/.env.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
HW_VERSION=your homework version here
1+
HW_VERSION=B

lesson_07/conditionals/src/part_b.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@
55
* @returns
66
*/
77
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+
821
return false;
922
}
1023

@@ -14,8 +27,16 @@ export function isLeapYear(year: number): boolean {
1427
* @param num
1528
* @returns
1629
*/
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.
1732
export function isEvenOrOdd(num: number): string {
1833
return "";
34+
if (num % 2 === 0) {
35+
return "even";
36+
}
37+
if (num % 3 === 0) {
38+
return "odd";
39+
}
1940
}
2041

2142
/**
@@ -24,6 +45,26 @@ export function isEvenOrOdd(num: number): string {
2445
* @param word
2546
* @returns
2647
*/
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+
2751
export function hasVowel(word: string): boolean {
28-
return false;
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+
}
2970
}

0 commit comments

Comments
 (0)