diff --git a/src/arrays.ts b/src/arrays.ts index d9ada59..7b28c21 100644 --- a/src/arrays.ts +++ b/src/arrays.ts @@ -11,9 +11,17 @@ function isArrayLengthOdd(numbers: number[]): boolean { // Your code here - + let count = 0; + for (let i = 0; i < numbers.length; i++) { + count += 1; + } + if (count % 2 !== 0) { + return true; + } return false; // replace false with what you see is fit } +console.log(isArrayLengthOdd([1, 2, 3])); +console.log(isArrayLengthOdd([1, 2, 3, 4])); /** * isArrayLengthEven(numbers): @@ -28,9 +36,17 @@ function isArrayLengthOdd(numbers: number[]): boolean { function isArrayLengthEven(numbers: number[]): boolean { // Your code here - + let count = 0; + for (let i = 0; i < numbers.length; i++) { + count += 1; + } + if (count % 2 == 0) { + return true; + } return false; // replace false with what you see is fit } +console.log(isArrayLengthEven([1, 2, 3])); +console.log(isArrayLengthEven([1, 2, 3, 4])); /** * addLailaToArray(instructors): @@ -42,10 +58,10 @@ function isArrayLengthEven(numbers: number[]): boolean { */ function addLailaToArray(instructors: string[]): string[] { // Your code here - - return []; // replace empty array with what you see is fit + instructors.push("laila"); + return instructors; // replace empty array with what you see is fit } - +console.log(addLailaToArray(["Mshary", "Hasan"])); /** * eliminateTeam(teams): * - Accepts a "teams" parameter of type "string[]" @@ -56,8 +72,9 @@ function addLailaToArray(instructors: string[]): string[] { */ function eliminateTeam(teams: string[]): string { // Your code here - - return ""; // replace empty string with what you see is fit + const eliminated = teams.pop(); + return eliminated!; // replace empty string with what you see is fit } +console.log(eliminateTeam(["Brazil", "Germany", "Italy"])); export { isArrayLengthOdd, isArrayLengthEven, addLailaToArray, eliminateTeam };