From 7bbcf7dcfc3331f4a7b7834fcaa5e841aaa08bb1 Mon Sep 17 00:00:00 2001 From: Abdullah Al-Rashidi Date: Tue, 22 Jul 2025 20:25:48 +0300 Subject: [PATCH] done --- src/functions.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/functions.ts b/src/functions.ts index 674ff85..3665384 100644 --- a/src/functions.ts +++ b/src/functions.ts @@ -8,6 +8,7 @@ */ function greet(name: string): void { // Your code here + console.log("Hello " + name); } /** @@ -21,8 +22,11 @@ function greet(name: string): void { */ function isOdd(n: number): boolean { // Your code here - - return false; // replace false with what you see is fit + if (n % 2 === 1) { + return true; + } else { + return false; // replace false with what you see is fit + } } /** @@ -36,8 +40,13 @@ function isOdd(n: number): boolean { */ function oddsSmallerThan(n: number): number { // Your code here - - return -1; // replace -1 with what you see is fit + let count = 0; + for (let i = 1; i < n; i++) { + if (i % 2 === 1) { + count = count + 1; + } + } + return count; // replace -1 with what you see is fit } /** @@ -52,8 +61,11 @@ function oddsSmallerThan(n: number): number { */ function squareOrDouble(n: number): number { // Your code here - - return -1; // replace -1 with what you see is fit + if (n % 2 === 1) { + return n * n; + } else { + return n * 2; // replace -1 with what you see is fit + } } export { greet, isOdd, oddsSmallerThan, squareOrDouble };