From a4c0d313154e54b9d37dd9995488ed64e20b6d0e Mon Sep 17 00:00:00 2001 From: A-M98 Date: Mon, 10 Mar 2025 12:17:06 +0300 Subject: [PATCH] Ahmed AL-Mohammed Dana Al-Dulijan --- src/arrays.ts | 17 +++++++++-------- src/challenge.ts | 10 +++++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/arrays.ts b/src/arrays.ts index d9ada59..f52d214 100644 --- a/src/arrays.ts +++ b/src/arrays.ts @@ -11,8 +11,8 @@ function isArrayLengthOdd(numbers: number[]): boolean { // Your code here - - return false; // replace false with what you see is fit + if (numbers.length % 2 == 1) return true; + else return false; // replace false with what you see is fit } /** @@ -28,8 +28,8 @@ function isArrayLengthOdd(numbers: number[]): boolean { function isArrayLengthEven(numbers: number[]): boolean { // Your code here - - return false; // replace false with what you see is fit + if (numbers.length % 2 == 0) return true; + else return false; // replace false with what you see is fit } /** @@ -42,8 +42,9 @@ function isArrayLengthEven(numbers: number[]): boolean { */ function addLailaToArray(instructors: string[]): string[] { // Your code here - - return []; // replace empty array with what you see is fit + var newArray: string[] = instructors; + newArray.push("Laila"); + return newArray; // replace empty array with what you see is fit } /** @@ -56,8 +57,8 @@ function addLailaToArray(instructors: string[]): string[] { */ function eliminateTeam(teams: string[]): string { // Your code here - - return ""; // replace empty string with what you see is fit + var eliminateTeam = teams.pop() ?? ""; + return eliminateTeam; // replace empty string with what you see is fit } export { isArrayLengthOdd, isArrayLengthEven, addLailaToArray, eliminateTeam }; diff --git a/src/challenge.ts b/src/challenge.ts index 620530f..80ce43c 100644 --- a/src/challenge.ts +++ b/src/challenge.ts @@ -14,8 +14,12 @@ */ function secondHalfOfArrayIfItIsEven(fruits: string[]): string[] { // Your code here + var secondHalf: string[]; + if (fruits.length % 2 == 0) + secondHalf = fruits.splice(fruits.length / 2, fruits.length / 2); + else secondHalf = []; - return []; // replace empty array with what you see is fit + return secondHalf; // replace empty array with what you see is fit } /** @@ -34,8 +38,8 @@ function secondHalfOfArrayIfItIsEven(fruits: string[]): string[] { */ function youGottaCalmDown(shout: string): string { // Your code here - - return ""; // replace the empty string with what you see is fit + let result = shout; + return result.replace(/!(?=.*!)/g, ""); // replace the empty string with what you see is fit } export { secondHalfOfArrayIfItIsEven, youGottaCalmDown };