Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 3 commits into
base: feedback
Choose a base branch
from
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
18 changes: 15 additions & 3 deletions src/math.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
// ### LEVEL 1: The Basics ###
export function add(x: number, y: number): number {
// TODO: Return the sum of x and y
throw new Error("Not implemented");
return x + y;
}

// ### LEVEL 2: Fizz Buzz ###
export function fizzBuzz(value: number): string {
// TODO: Return Fizz if value is divisible by 3, Buzz if value is divisible by 5,
// FizzBuzz if value is divisible by 3 and 5, and the value as a string otherwise
throw new Error("Not implemented");
if (value % 3 === 0) {
if (value % 5 === 0) {
return "FizzBuzz";
}

return "Fizz";
}

if (value % 5 === 0) {
return "Buzz";
}

return value.toString();
}

// ### LEVEL 3: Length of vector ###
export function getLengthOfVector(vec: [number, number]): number {
// TODO: Return the length of the vector
throw new Error("Not implemented");
return Math.sqrt(vec[0] * vec[0] + vec[1] * vec[1]);
}