Skip to content
Open

done #25

Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* greet("Hamza") logs "Hello Hamza"
*/
function greet(name: string): void {
// Your code here
console.log(`Hello ${name}`);
}

/**
Expand All @@ -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
}

/**
Expand All @@ -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):
Expand All @@ -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 };