Skip to content
Closed

done #20

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
24 changes: 18 additions & 6 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,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
}
}

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

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