Skip to content
Open

Done #21

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions src/arrays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand All @@ -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[]"
Expand All @@ -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 };
Loading