Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8907408
Initial commit
Konvaly Oct 31, 2025
e113639
Solved task 1-key-errors/0.js
Konvaly Nov 1, 2025
83a2f87
Solved task 1-key-errors/1.js
Konvaly Nov 1, 2025
ea085d9
Solved task 1-key-errors/2.js
Konvaly Nov 1, 2025
2d4152e
Solved task 2-mandatory-debug/0.js
Konvaly Nov 1, 2025
0b216d5
Solved task 2-mandatory-debug/1.js
Konvaly Nov 1, 2025
e0d30d1
Solved task 2-mandatory-debug/2.js
Konvaly Nov 1, 2025
ec8c0e5
Solved task 3-mandatory-implement/1-bmi.js
Konvaly Nov 1, 2025
0606e40
Solved task 3-mandatory-implement/2-cases.js
Konvaly Nov 1, 2025
b4c62e1
Solved task 3-mandatory-implement/3-to-pounds.js
Konvaly Nov 1, 2025
f5ab7c1
Solved task 4-mandatory-interpret/time-format.js
Konvaly Nov 1, 2025
9d2753f
Remove package-lock.json from tracking
Konvaly Nov 5, 2025
83547a2
Fixed and updated files in Sprint-2
Konvaly Nov 5, 2025
47782ce
Solved task 1-implement/1-get-angle-type.js
Konvaly Nov 10, 2025
0eef99b
Solved task 1-implement/2-is-proper-fraction.js
Konvaly Nov 10, 2025
2462c94
Solved task 1-implement/3-get-card-value.js
Konvaly Nov 10, 2025
24010e0
Solved task 3/1-implement-and-rewrite-tests/implement/3-get-card-valu…
Konvaly Nov 10, 2025
9e5e069
Solved task 3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1…
Konvaly Nov 10, 2025
41f0a01
Solved task Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with…
Konvaly Nov 10, 2025
aa82bda
Solved task Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with…
Konvaly Nov 10, 2025
878ee90
Cleanup: Reverted all Sprint-2 related code from this Sprint-3 branch.
Konvaly Nov 17, 2025
c45cf70
Fixed wrong if-statements in the 2-is-proper-fraction.js
Konvaly Nov 20, 2025
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
2 changes: 1 addition & 1 deletion Sprint-2/1-key-errors/0.js

Choose a reason for hiding this comment

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

Please write your explanation and the new code, follow the instructions.

Copy link
Author

@Konvaly Konvaly Nov 20, 2025

Choose a reason for hiding this comment

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

For this task Sprint-2/1-key-errors/0.js - there is no code because this task should be in Sprint-2 and I mistakenly created new branch not from "main" but from the branch Sprint-2. After that I reverted this action (so explanation and the new code are in the another PR, which is already reviewed).

Choose a reason for hiding this comment

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

okay

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Predict and explain first...
// =============> write your prediction here
// I guess that the error could be due to the having the same variable in parameter and in the function body.

// call the function capitalise with a string input
// interpret the error message and figure out why an error is occurring
Expand Down
Copy link

@A-O-Emmanuel A-O-Emmanuel Nov 19, 2025

Choose a reason for hiding this comment

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

This meets the acceptance criteria.

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,20 @@ function getAngleType(angle) {
if (angle === 90) {
return "Right angle";
}
// Run the tests, work out what Case 2 is testing, and implement the required code here.
// Then keep going for the other cases, one at a time.
// Run the tests, work out what Case 2 is testing, and implement the required code here.
// Then keep going for the other cases, one at a time.
if (angle < 90) {
return "Acute angle";
}
if (angle > 90 && angle < 180) {
return "Obtuse angle";
}
if (angle === 180) {
return "Straight angle";
}
if (angle > 180 && angle < 360) {
return "Reflex angle";
}
}

// The line below allows us to load the getAngleType function into tests in other files.
Expand Down Expand Up @@ -50,14 +62,16 @@ assertEquals(acute, "Acute angle");
// When the angle is greater than 90 degrees and less than 180 degrees,
// Then the function should return "Obtuse angle"
const obtuse = getAngleType(120);
// ====> write your test here, and then add a line to pass the test in the function above
assertEquals(obtuse, "Obtuse angle");

// Case 4: Identify Straight Angles:
// When the angle is exactly 180 degrees,
// Then the function should return "Straight angle"
// ====> write your test here, and then add a line to pass the test in the function above
const straight = getAngleType(180);
assertEquals(straight, "Straight angle");

// Case 5: Identify Reflex Angles:
// When the angle is greater than 180 degrees and less than 360 degrees,
// Then the function should return "Reflex angle"
// ====> write your test here, and then add a line to pass the test in the function above
const reflex = getAngleType(210);
assertEquals(reflex, "Reflex angle");

Choose a reason for hiding this comment

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

Please check the acceptance criteria very well, for what you need to do, the last two if statements do not align with their respective acceptance criteria

Copy link
Author

Choose a reason for hiding this comment

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

I 've fixed if statements and rewritten test case "Both Numerator and Denominator Negative check"

Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
// write one test at a time, and make it pass, build your solution up methodically

function isProperFraction(numerator, denominator) {
if (numerator < denominator) {
if (denominator === 0) {
return false;
}
if (Math.abs(numerator) < Math.abs(denominator)) {
return true;
}
return false;
}

// The line below allows us to load the isProperFraction function into tests in other files.
Expand Down Expand Up @@ -46,14 +50,35 @@ assertEquals(improperFraction, false);
// target output: true
// Explanation: The fraction -4/7 is a proper fraction because the absolute value of the numerator (4) is less than the denominator (7). The function should return true.
const negativeFraction = isProperFraction(-4, 7);
// ====> complete with your assertion
assertEquals(negativeFraction, true);

// Equal Numerator and Denominator check:
// Input: numerator = 3, denominator = 3
// target output: false
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false.
const equalFraction = isProperFraction(3, 3);
// ====> complete with your assertion
assertEquals(equalFraction, false);

// Stretch:
// What other scenarios could you test for?

// Both Numerator and Denominator Negative check:
// Input: numerator = -4, denominator = -9
// target output: false
// Explanation: The fraction -4/-9 is equivalent to 4/9, which is a proper fraction. Function should return false.
const bothNegative = isProperFraction(-4, -9);
assertEquals(bothNegative, true);

// Zero Numerator check:
// Input: numerator = 0, denominator = 7
// target output: true
// Explanation: The fraction 0/7 is a proper fraction because the numerator is less than the denominator. The function should return true.
const zeroNumerator = isProperFraction(0, 7);
assertEquals(zeroNumerator, true);

// Zero Denominator check:
// Input: numerator = 2, denominator = 0
// target output: false
// Explanation: The fraction 2/0 is undefined because division by zero is not allowed. The function should return false.
const zeroDenominator = isProperFraction(2, 0);
assertEquals(zeroDenominator, false);
Copy link

@A-O-Emmanuel A-O-Emmanuel Nov 20, 2025

Choose a reason for hiding this comment

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

This is okay

Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,28 @@
// write one test at a time, and make it pass, build your solution up methodically
// just make one change at a time -- don't rush -- programmers are deep and careful thinkers
function getCardValue(card) {
const rank = card.slice(0, -1);
const cardFace = card.slice(-1);
const numRank = Number(rank);
const allowedCardFaces = ["♠", "♣", "♦", "♥"];

if (!allowedCardFaces.includes(cardFace)) {
return "Invalid card face.";
}

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

if (rank === "10" || rank === "J" || rank === "Q" || rank === "K") {
return 10;
}

if (Number.isInteger(numRank) && numRank >= 2 && numRank <= 9) {
return numRank;
} else {
return "Invalid card rank.";
}
}

// The line below allows us to load the getCardValue function into tests in other files.
Expand Down Expand Up @@ -39,19 +58,46 @@ assertEquals(aceofSpades, 11);
// When the function is called with such a card,
// Then it should return the numeric value corresponding to the rank (e.g., "5" should return 5).
const fiveofHearts = getCardValue("5♥");
// ====> write your test here, and then add a line to pass the test in the function above
assertEquals(fiveofHearts, 5);

// Handle Face Cards (J, Q, K):
// Given a card with a rank of "10," "J," "Q," or "K",
// When the function is called with such a card,
// Then it should return the value 10, as these cards are worth 10 points each in blackjack.
const tenOfDiamonds = getCardValue("10♦");
assertEquals(tenOfDiamonds, 10);
const jackOfClubs = getCardValue("J♣");
assertEquals(jackOfClubs, 10);
const queenOfSpades = getCardValue("Q♠");
assertEquals(queenOfSpades, 10);
const kingOfHearts = getCardValue("K♥");
assertEquals(kingOfHearts, 10);

// Handle Ace (A):
// Given a card with a rank of "A",
// When the function is called with an Ace,
// Then it should, by default, assume the Ace is worth 11 points, which is a common rule in blackjack.
const aceOfDiamonds = getCardValue("A♦");
assertEquals(aceOfDiamonds, 11);
const aceOfClubs = getCardValue("A♣");
assertEquals(aceOfClubs, 11);
const aceOfHearts = getCardValue("A♥");
assertEquals(aceOfHearts, 11);
//Actually, these cases already covered in the function getCardValue()

// Handle Invalid Cards:
// Given a card with an invalid rank (neither a number nor a recognized face card),
// When the function is called with such a card,
// Then it should throw an error indicating "Invalid card rank."
const invalidNumberCard = getCardValue("12♥");
assertEquals(invalidNumberCard, "Invalid card rank.");
const invalidFaceCard = getCardValue("5*");
assertEquals(invalidFaceCard, "Invalid card face.");
const invalidFaceCard10 = getCardValue("10$");
assertEquals(invalidFaceCard10, "Invalid card face.");
const invalidFaceCardJack = getCardValue("J%");
assertEquals(invalidFaceCardJack, "Invalid card face.");
const invalidFaceCardQueen = getCardValue("Q£");
assertEquals(invalidFaceCardQueen, "Invalid card face.");
const invalidFaceCardKing = getCardValue("K^");
assertEquals(invalidFaceCardKing, "Invalid card face.");
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,27 @@ test("should identify right angle (90°)", () => {
// Case 2: Identify Acute Angles:
// When the angle is less than 90 degrees,
// Then the function should return "Acute angle"
test("should identify acute angle - less than 90°", () => {
expect(getAngleType(78)).toEqual("Acute angle");
});

// Case 3: Identify Obtuse Angles:
// When the angle is greater than 90 degrees and less than 180 degrees,
// Then the function should return "Obtuse angle"
test("should identify obtuse angle - greater than 90° and less than 180°", () => {
expect(getAngleType(150)).toEqual("Obtuse angle");
});

// Case 4: Identify Straight Angles:
// When the angle is exactly 180 degrees,
// Then the function should return "Straight angle"
test("should identify straight angle - is exactly 180°", () => {
expect(getAngleType(180)).toEqual("Straight angle");
});

// Case 5: Identify Reflex Angles:
// When the angle is greater than 180 degrees and less than 360 degrees,
// Then the function should return "Reflex angle"
test("should identify reflex angle - greater than 180° and less than 360°", () => {
expect(getAngleType(230)).toEqual("Reflex angle");
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ test("should return true for a proper fraction", () => {
});

// Case 2: Identify Improper Fractions:
test("should return false for an improper fraction", () => {
expect(isProperFraction(5, 3)).toEqual(false);
});

// Case 3: Identify Negative Fractions:
test("should return true for a negative fraction", () => {
expect(isProperFraction(-6, 10)).toEqual(true);
});

// Case 4: Identify Equal Numerator and Denominator:
test("should return false for the fraction with equal numerator and denominator", () => {
expect(isProperFraction(7, 7)).toEqual(false);
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,44 @@ test("should return 11 for Ace of Spades", () => {
});

// Case 2: Handle Number Cards (2-10):
test("should return the numeric value between '2' and '10', corresponding to the rank (e.g., '2' should return 2)", () => {
const fiveOfHearts = getCardValue("5♥");
expect(fiveOfHearts).toEqual(5);
});

// Case 3: Handle Face Cards (J, Q, K):
test("should return the value 10, as these cards (J, Q, K) are worth 10 points each in blackjack", () => {
const jackOfClubs = getCardValue("J♣");
expect(jackOfClubs).toEqual(10);
const queenOfSpades = getCardValue("Q♠");
expect(queenOfSpades).toEqual(10);
const kingOfHearts = getCardValue("K♥");
expect(kingOfHearts).toEqual(10);
});

// Case 4: Handle Ace (A):
// Actually, I guess will be better to combine all case tests for aces in one, but case for Ace of Spaces already covered in Case 1
test("should return 11 for a card with a rank of 'A'", () => {
const aceOfDiamonds = getCardValue("A♦");
expect(aceOfDiamonds).toEqual(11);
const aceOfClubs = getCardValue("A♣");
expect(aceOfClubs).toEqual(11);
const aceOfHearts = getCardValue("A♥");
expect(aceOfHearts).toEqual(11);
});

// Case 5: Handle Invalid Cards:
test("should throw an error indicating 'Invalid card rank.' or 'Invalid card face.' when given a card with an invalid rank (neither a number nor a recognized face card)", () => {
const invalidNumberCard = getCardValue("12♥");
expect(invalidNumberCard).toEqual("Invalid card rank.");
const invalidFaceCard = getCardValue("5*");
expect(invalidFaceCard).toEqual("Invalid card face.");
const invalidFaceCard10 = getCardValue("10$");
expect(invalidFaceCard10).toEqual("Invalid card face.");
const invalidFaceCardJack = getCardValue("J%");
expect(invalidFaceCardJack).toEqual("Invalid card face.");
const invalidFaceCardQueen = getCardValue("Q£");
expect(invalidFaceCardQueen).toEqual("Invalid card face.");
const invalidFaceCardKing = getCardValue("K^");
expect(invalidFaceCardKing).toEqual("Invalid card face.");
});
Loading