diff --git a/package-lock.json b/package-lock.json index 209bf32..38e143a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -67,6 +67,7 @@ "integrity": "sha512-lWBYIrF7qK5+GjY5Uy+/hEgp8OJWOD/rpy74GplYRhEauvbHDeFB8t5hPOZxCZ0Oxf4Cc36tK51/l3ymJysrKw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.26.2", @@ -1417,6 +1418,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001688", "electron-to-chromium": "^1.5.73", @@ -2617,6 +2619,7 @@ "integrity": "sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@jest/core": "^29.7.0", "@jest/types": "^29.6.3", diff --git a/src/functions.ts b/src/functions.ts index 674ff85..1bdf04a 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}`); } /** @@ -21,8 +21,8 @@ function greet(name: string): void { */ 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,10 +35,10 @@ 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 -} + if (n <= 1) return 0; // Edge case: no odd numbers smaller + return Math.floor(n / 2); // Formula: half of n (rounded down) + } + // replace -1 with what you see is fit /** * squareOrDouble(n): @@ -52,8 +52,8 @@ 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 !== 0) { + return n * n; +} else return n * 2; } - export { greet, isOdd, oddsSmallerThan, squareOrDouble };