Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4c62400
updated 1-count.js with an explanation of line 3
JorvanW Jun 10, 2026
376a6b0
added answers to 0.js
Jun 27, 2026
2323e10
Added notes for 1.js
Jun 27, 2026
87fbee5
added notes for 2.js
Jun 27, 2026
57e3a65
added notes to 0.js
Jun 29, 2026
bf5c332
added answer to 0.js
Jun 29, 2026
4ca3f91
added notes to 1.js
Jun 29, 2026
185c7e7
added answers to 2.js
Jun 29, 2026
195189a
completed. 1-bmi
Jul 4, 2026
3f957a1
Answered the questions for 2-cases.js
Jul 4, 2026
b48031e
Added answers to the questions in the time-format.js file.
Jul 8, 2026
216221a
Created code for 1-get-angle-type.js
Jul 14, 2026
d10fc3c
fixed error in 'get-angle-types' and changed "let" to "function".
Jul 14, 2026
60638b4
wrote code for "is-proper-fraction" function and added test cases for it
Jul 14, 2026
2ac2702
Added code for 1-get-angle-type.test.js to include a test case for ea…
Jul 14, 2026
f8cf7cf
added code to test 2-is-proper-fraction.test.js
Jul 14, 2026
f3f69db
Add count function and tests
Jul 15, 2026
f6f3d1d
Remove CLI-Treasure-Hunt subproject from Sprint-2
Jul 15, 2026
0bdef75
Add functions and test for get-ordinal-number.js
Jul 15, 2026
630c502
removed unnecessary code and simplified it in excersie-1.js
Jul 15, 2026
55740a4
Removed dead code in exercise-2
Jul 15, 2026
6994606
Added code for repeat-string .js
Jul 17, 2026
e54bbd5
added code for 3-get-card-value.js
Jul 22, 2026
9aaaa7e
added tests for 3-get-card-value.test.js
Jul 22, 2026
7cacfb4
added notes for 3-get-card-value.js
Jul 22, 2026
a6131ab
updated formatting errors in 1-get-angle-types and 2-is-proper-faction
Jul 22, 2026
a85a823
updated code and added tests for repeat.str
Jul 22, 2026
cc958de
removed code from Sprint-2
Aug 3, 2026
919dba4
removed line of code from sprint -1
Aug 3, 2026
6e8feda
Updated sprint for PR
Aug 3, 2026
d9b6d56
added 4 more test cases for 1-get-angle-type-test
Aug 10, 2026
e20bb70
changed code to use math.abs in 2-is-proper-fraction
Aug 10, 2026
a41e976
updated code and test cases for 2-is-proper-fraction
Aug 10, 2026
836cce7
added more test cases for 3-get-card-value
Aug 10, 2026
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,26 @@
// execute the code to ensure all tests pass.

function getAngleType(angle) {
{
if (angle > 0 && angle < 90) {
return "Acute angle";
}
if (angle === 90) {
return "Right angle";
}
if (angle > 90 && angle < 180) {
return "Obtuse angle";
}
if (angle === 180) {
return "Straight angle";
}
if (angle > 180 && angle < 360) {
return "Reflex angle";
}
return "Invalid angle";
}


// TODO: Implement this function
}

Expand All @@ -35,3 +55,6 @@ function assertEquals(actualOutput, targetOutput) {
// Example: Identify Right Angles
const right = getAngleType(90);
assertEquals(right, "Right angle");



Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
// After you have implemented the function, write tests to cover all the cases, and
// execute the code to ensure all tests pass.

function isProperFraction(numerator, denominator) {
// TODO: Implement this function
}

// The line below allows us to load the isProperFraction function into tests in other files.
// This will be useful in the "rewrite tests with jest" step.
module.exports = isProperFraction;
Expand All @@ -31,3 +27,20 @@ function assertEquals(actualOutput, targetOutput) {

// Example: 1/2 is a proper fraction
assertEquals(isProperFraction(1, 2), true);

function isProperFraction(numerator, denominator) {
if (typeof numerator !== "number" || typeof denominator !== "number") {
throw new Error("Numerator and denominator must be numbers");
}
if (denominator === 0) {
return false;
}
if (Math.abs(numerator) < Math.abs(denominator)) {
//Math.abs gives an absolute version of a number regardless of positive or negative
return true;
}
return false;
}
console.log(isProperFraction(2, 3)); // true

module.exports = isProperFraction;
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,31 @@
// execute the code to ensure all tests pass.

function getCardValue(card) {
// TODO: Implement this function
const suit = card.slice(-1);
const rank = card.slice(0, -1);

const validSuits = ["♠", "♥", "♦", "♣"];

if (!validSuits.includes(suit)) {
throw new Error("Invalid card");
}

if (rank === "A") {
return 11;
}

if (["J", "Q", "K"].includes(rank)) {
return 10;
}

if (["2", "3", "4", "5", "6", "7", "8", "9", "10"].includes(rank)) {
return Number(rank);
}

throw new Error("Invalid card");
}


// The line below allows us to load the getCardValue function into tests in other files.
// This will be useful in the "rewrite tests with jest" step.
module.exports = getCardValue;
Expand Down Expand Up @@ -52,3 +74,6 @@ try {
}

// What other invalid card cases can you think of?
// logging cards without suits to throw error


Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,66 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => {
});

// Case 2: Right angle
test(`should return "Right angle" when (angle === 90)`, () => {
// Test various acute angles, including boundary cases
expect(getAngleType(90)).toEqual("Right angle");
});

// Case 3: Obtuse angles
test(`should return "Obtuse angle" when (90 < angle < 180)`, () => {
// Test various obtuse angles, including boundary cases
expect(getAngleType(91)).toEqual("Obtuse angle");
expect(getAngleType(135)).toEqual("Obtuse angle");
expect(getAngleType(179)).toEqual("Obtuse angle");
});

// Case 4: Straight angle
test(`should return "Straight angle" when (angle === 180)`, () => {
// Test various acute angles, including boundary cases
expect(getAngleType(180)).toEqual("Straight angle");
});

// Case 5: Reflex angles
test(`should return "Reflex angle" when (180 < angle < 360)`, () => {
// Test various reflex angles, including boundary cases
expect(getAngleType(181)).toEqual("Reflex angle");
expect(getAngleType(270)).toEqual("Reflex angle");
expect(getAngleType(359)).toEqual("Reflex angle");
});

// Case 6: Invalid angles
test(`should return "Invalid angle" when (angle < 0 || angle > 360)`, () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Besides -1 and 361, it should include the two boundary cases as well.

// Test various invalid angles
expect(getAngleType(-1)).toEqual("Invalid angle");
expect(getAngleType(361)).toEqual("Invalid angle");
});

// Case 7: Invalid Non-numeric inputs
test("should return Invalid angle for non-number inputs", () => {
expect(getAngleType("90")).toEqual("Invalid angle");
expect(getAngleType("hello")).toEqual("Invalid angle");
});

// Case 8: Decimal angles
test("should handle decimal angles", () => {
expect(getAngleType(0.5)).toEqual("Acute angle");
expect(getAngleType(89.5)).toEqual("Acute angle");
expect(getAngleType(90.5)).toEqual("Obtuse angle");
expect(getAngleType(179.5)).toEqual("Obtuse angle");
expect(getAngleType(180.5)).toEqual("Reflex angle");
expect(getAngleType(359.5)).toEqual("Reflex angle");
});

// Case 9: Very large numbers
test("should return Invalid angle for angles above 360", () => {
expect(getAngleType(361)).toEqual("Invalid angle");
expect(getAngleType(720)).toEqual("Invalid angle");
expect(getAngleType(1000)).toEqual("Invalid angle");
});

// Case 10: Very large negative numbers
test("should return Invalid angle for negative angles", () => {
expect(getAngleType(-1)).toEqual("Invalid angle");
expect(getAngleType(-90)).toEqual("Invalid angle");
expect(getAngleType(-360)).toEqual("Invalid angle");
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

there should be more negative number test cases. Can you think of them?

Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,36 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
test(`should return false when denominator is zero`, () => {
expect(isProperFraction(1, 0)).toEqual(false);
});

test(`should return true when numerator is zero`, () => {
expect(isProperFraction(0, 3)).toEqual(true);
});

test(`should return false when both numerator and denominator are zero`, () => {
expect(isProperFraction(0, 0)).toEqual(false);
});

test(`should return false when both numerator and denominator are the same number`, () => {
expect(isProperFraction(3, 3)).toEqual(false);
});

test(`should return true when numerator is less than denominator`, () => {
expect(isProperFraction(1, 2)).toEqual(true);
expect(isProperFraction(-1, -2)).toEqual(true);
});

test(`should return false when numerator is equal to denominator`, () => {
expect(isProperFraction(2, 2)).toEqual(false);
expect(isProperFraction(-2, -2)).toEqual(false);
});

test(`should return false when numerator is greater than denominator`, () => {
expect(isProperFraction(3, 2)).toEqual(false);
expect(isProperFraction(-3, -2)).toEqual(false);
});

test("should throw an error for non-numerical values", () => {
expect(() => isProperFraction("2", 3)).toThrow(
"Numerator and denominator must be numbers"
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,62 @@ test(`Should return 11 when given an ace card`, () => {
});

// Suggestion: Group the remaining test data into these categories:
// Number Cards (2-10)
// Face Cards (J, Q, K)

// Case 2: Number Cards (2-10)
test(`Should return the same number when given a number card of any suit`, () => {
expect(getCardValue("3♠")).toEqual(3);
expect(getCardValue("5♥")).toEqual(5);
expect(getCardValue("9♦")).toEqual(9);
expect(getCardValue("10♣")).toEqual(10);
});

// Case 3: Valid Suits
test("Should accept all valid suits", () => {
expect(getCardValue("A♠")).toEqual(11);
expect(getCardValue("A♥")).toEqual(11);
expect(getCardValue("A♦")).toEqual(11);
expect(getCardValue("A♣")).toEqual(11);
});

// Case 4: Face Cards (J, Q, K)
test(`Should return 10 when given an any face card`, () => {
expect(getCardValue("J♠")).toEqual(10);
expect(getCardValue("Q♥")).toEqual(10);
expect(getCardValue("K♦")).toEqual(10);
});

// Invalid Cards

// Test 5: Non-suit inputs
test("Cards without suits throw an error", () => {
expect(() => {
getCardValue("10");
}).toThrow("Invalid card");
});
Comment on lines +37 to +44

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

there should be more invalid cases, Can you think of them?


// Test 6: Invalid suits
test("Should throw an error for an invalid suit", () => {
expect(() => getCardValue("A★")).toThrow("Invalid card");
});

// Test 7: Invalid rank
test("Should throw an error for an invalid rank", () => {
expect(() => getCardValue("Z♠")).toThrow("Invalid card");
});

// Test 8: Invalid input
test("Should throw an error for an invalid card", () => {
expect(() => getCardValue("hello")).toThrow("Invalid card");
});

// Test 9: Reject lowercase card ranks
test("Should reject lowercase card ranks", () => {
expect(() => getCardValue("a♠")).toThrow("Invalid card");
expect(() => getCardValue("j♠")).toThrow("Invalid card");
expect(() => getCardValue("q♠")).toThrow("Invalid card");
expect(() => getCardValue("k♠")).toThrow("Invalid card");
});

// To learn how to test whether a function throws an error as expected in Jest,
// please refer to the Jest documentation:
// https://jestjs.io/docs/expect#tothrowerror

Loading