From 78cd26943f1ede59abecccbceb9f7840420dc57c Mon Sep 17 00:00:00 2001 From: bequit1 Date: Fri, 25 Jul 2025 14:37:31 +0300 Subject: [PATCH] finish function p2 --- src/functions.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/functions.ts b/src/functions.ts index 674ff85..59b67a1 100644 --- a/src/functions.ts +++ b/src/functions.ts @@ -7,7 +7,7 @@ * greet("Hamza") logs "Hello Hamza" */ function greet(name: string): void { - // Your code here + console.log(`Hello ${name}`); } /** @@ -20,9 +20,7 @@ function greet(name: string): void { * isOdd(10) -> false */ function isOdd(n: number): boolean { - // Your code here - - return false; // replace false with what you see is fit + return n % 2 !== 0; // replace false with what you see is fit } /** @@ -35,9 +33,8 @@ function isOdd(n: number): boolean { * oddsSmallerThan(15) -> 7; // the odd numbers being 1, 3, 5, 7, 9, 11, 13 */ function oddsSmallerThan(n: number): number { - // Your code here - - return -1; // replace -1 with what you see is fit + return Math.floor(n / 2); + // replace -1 with what you see is fit } /** @@ -51,9 +48,12 @@ function oddsSmallerThan(n: number): number { * squareOrDouble(9) -> 81; // (9 ^ 2) */ function squareOrDouble(n: number): number { - // Your code here - - return -1; // replace -1 with what you see is fit + if (n % 2 === 0) { + return n * 2; + } else { + return n * n; + } + // replace -1 with what you see is fit } export { greet, isOdd, oddsSmallerThan, squareOrDouble };