Skip to content
Open
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
14 changes: 9 additions & 5 deletions src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
function greet(name: string): void {
// Your code here
console.log(`Hello ${name}`)
}

/**
Expand All @@ -21,7 +22,8 @@ function greet(name: string): void {
*/
function isOdd(n: number): boolean {
// Your code here

if(n%2 !== 0)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also just do:

function isOdd(n: number): boolean {
    return n%2 !== 0;
}

return true;
return false; // replace false with what you see is fit
}

Expand All @@ -36,8 +38,9 @@ function isOdd(n: number): boolean {
*/
function oddsSmallerThan(n: number): number {
// Your code here

return -1; // replace -1 with what you see is fit
if(n%2 !== 0)
return (n-1)/2;
return n/2; // replace -1 with what you see is fit
}

/**
Expand All @@ -52,8 +55,9 @@ 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**2;
return n*2; // replace -1 with what you see is fit
}

export { greet, isOdd, oddsSmallerThan, squareOrDouble };