From d91a6c0664f1aad6001073bd7a18d7d5d1ee8d40 Mon Sep 17 00:00:00 2001 From: "github-classroom[bot]" <66690702+github-classroom[bot]@users.noreply.github.com> Date: Thu, 13 Oct 2022 10:59:31 +0000 Subject: [PATCH 1/3] Setting up GitHub Classroom Feedback From 2b62850a929970a6ed2dfa711f89aae312c190e8 Mon Sep 17 00:00:00 2001 From: ASchabus Date: Thu, 13 Oct 2022 13:19:11 +0200 Subject: [PATCH 2/3] Add solution for Level 1 --- src/math.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/math.ts b/src/math.ts index ea72e07..8aa9693 100644 --- a/src/math.ts +++ b/src/math.ts @@ -1,7 +1,7 @@ // ### 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 ### From 7c322789510c989ed799bab31ffc51e147613e79 Mon Sep 17 00:00:00 2001 From: ASchabus Date: Thu, 13 Oct 2022 13:33:02 +0200 Subject: [PATCH 3/3] Finally I also pushed my changes --- src/math.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/math.ts b/src/math.ts index 8aa9693..ca396d4 100644 --- a/src/math.ts +++ b/src/math.ts @@ -8,11 +8,23 @@ export function add(x: number, y: number): number { 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]); }