Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
d0f5f37
Implemented case 2: Identify Acute Angles for getAngleType in 1-get-a…
kolya-rm Dec 16, 2025
099d53a
Added test for case 3: Identify Obtuse Angel 1-get-angle-type.js in k…
kolya-rm Dec 16, 2025
cb211f7
Update test for case 3: Identify obtuse angle in 1-get-angle-type.js …
kolya-rm Dec 16, 2025
398f381
Implemeted the function behaviour for case 3: Identify Obtuse Angle f…
kolya-rm Dec 16, 2025
7116b75
Added case 4: Identify Straight Angles test in 1-get-angle-type.js fo…
kolya-rm Dec 16, 2025
e3590e3
Implemented function logic for case 4: Identify Stright Angle in 1-ge…
kolya-rm Dec 16, 2025
5d71909
Added test for case 5: Identify reflex Angles in 1-get-angle-type.js …
kolya-rm Dec 16, 2025
dc7b8bf
Implemented function logic for case 5: Identify Reflex Angle 1-get-an…
kolya-rm Dec 16, 2025
194539c
Implemented the function logic for Improper Fraction check in 2-is-pr…
kolya-rm Dec 16, 2025
b66cecb
Added the assertion for Negative fraction check in 2-is-proper-fracti…
kolya-rm Dec 16, 2025
626ac9e
Added the assertion for Equal numerator and denominator chack in 2-is…
kolya-rm Dec 16, 2025
b6729fa
Added assertion for Negative numerator with absolute value greater th…
kolya-rm Dec 16, 2025
96cd568
Implemets the function logic for case Negative numerator with absolut…
kolya-rm Dec 16, 2025
42a299c
Added assertion for case of the negative denominator with the absolut…
kolya-rm Dec 16, 2025
d08fc1e
Implemented the function logic for case of the negative denominator w…
kolya-rm Dec 16, 2025
e0874e7
Added the assertion for the case of negative denominator with absolut…
kolya-rm Dec 16, 2025
d0d6bcf
Added the assertion for the case then both values negative and numera…
kolya-rm Dec 16, 2025
7ee33b3
Added the asertion for the case wen both parts are negative and the n…
kolya-rm Dec 16, 2025
999a10f
Added the assertion for the case with equal negative numerator and de…
kolya-rm Dec 16, 2025
dbe15de
Added the assertion for the case of zero numerator in 2-is-proper-frc…
kolya-rm Dec 16, 2025
19522b3
Added the assertion for the case of zero denominator in 2-is-proper-f…
kolya-rm Dec 16, 2025
bb25404
Update the function logic in 2-is-proper-fraction.js sprint 3 key imp…
kolya-rm Dec 16, 2025
5c84687
Implemented
kolya-rm Dec 17, 2025
e6d27df
Implemented determination the rank of card logic. Implemented calcula…
kolya-rm Dec 17, 2025
2e04439
Added the assertion for the number cards case.
kolya-rm Dec 17, 2025
8dee5b4
Implemented logic for handling Number cards. Added assertions for mis…
kolya-rm Dec 17, 2025
71a2225
Added assertion for Face card cases to handle tens, jacks, queens, ki…
kolya-rm Dec 17, 2025
1b5420a
Fixed assertions for Face cards, added function call for cards strings.
kolya-rm Dec 17, 2025
41d33ea
Implemented function logic for handle Face cards.
kolya-rm Dec 17, 2025
aa99330
Moved the Ace case assertion and logic code for consistently reasons.
kolya-rm Dec 17, 2025
281bcaa
Added function calling for invalid cards.
kolya-rm Dec 17, 2025
b0d255c
Added Invalid card rank error throw.
kolya-rm Dec 17, 2025
f8d1b8e
Merge branch 'coursework/sprint-3' of github.com:kolya-rm/Module-Stru…
kolya-rm Dec 17, 2025
423908a
Copied th getAngleType(angle) function implementation from 1-key-impl…
kolya-rm Dec 18, 2025
e40ee60
Implemented a test for getAngleType(angle) function for the case of a…
kolya-rm Dec 18, 2025
c82c1fe
Implemented a test for getAngleType(angle) function for the case of o…
kolya-rm Dec 18, 2025
8b8cc2a
Implemented a test for getAngleType(angle) function for the case of s…
kolya-rm Dec 18, 2025
11265a6
Implemented a test for getAngleType(angle) function for the case of r…
kolya-rm Dec 18, 2025
f5079c3
Copied the isProperFraction(numerator, denominator) function implemen…
kolya-rm Dec 18, 2025
75ec3e5
Implemet a test for the isProperFrcation(numeratot, denominator) func…
kolya-rm Dec 18, 2025
00b30d9
Implemet a test for the isProperFrcation(numeratot, denominator) func…
kolya-rm Dec 18, 2025
12f638f
Implemet a test for the isProperFrcation(numeratot, denominator) func…
kolya-rm Dec 18, 2025
59c7010
Implemet a test for the isProperFrcation(numeratot, denominator) func…
kolya-rm Dec 18, 2025
aa2055d
Implemet a test for the isProperFrcation(numeratot, denominator) func…
kolya-rm Dec 18, 2025
9d7b538
Implemet a test for the isProperFrcation(numeratot, denominator) func…
kolya-rm Dec 18, 2025
56eea03
Implemet a test for the isProperFrcation(numeratot, denominator) func…
kolya-rm Dec 18, 2025
04427e8
Implemet a test for the isProperFrcation(numeratot, denominator) func…
kolya-rm Dec 18, 2025
38b36c4
Implemet a test for the isProperFrcation(numeratot, denominator) func…
kolya-rm Dec 18, 2025
276f7e7
Implemet a test for the isProperFrcation(numeratot, denominator) func…
kolya-rm Dec 18, 2025
a06d634
Implemet a test for the isProperFrcation(numeratot, denominator) func…
kolya-rm Dec 18, 2025
a3fc541
Fixed error in assertion case of zero denominator for function isProp…
kolya-rm Dec 18, 2025
968f227
Copied the logic implementation for the getCardValue(card) function …
kolya-rm Dec 18, 2025
a61f584
Implemented tests for Number cards for the getCardValue(card) functio…
kolya-rm Dec 18, 2025
1a6b8d0
Implemented test for cards of Nine for the getCardValue(card) functio…
kolya-rm Dec 18, 2025
7e6b899
Implemented tests for Face cards for the getCardValue(card) function …
kolya-rm Dec 18, 2025
ec83b75
Moved the test implementation for Ace cards for the getCardValue(card…
kolya-rm Dec 18, 2025
796d974
Moved test for cards of Ten for the getCardValue(card) function in th…
kolya-rm Dec 18, 2025
daccbe1
Update logic of the getCardValue(card) function. Case of cards of Ten…
kolya-rm Dec 18, 2025
423111c
Implemented tests for handling errors of Invalid cards for the getCar…
kolya-rm Dec 18, 2025
6c1ba58
Added a test for the countChar(string, char) function in case of the …
kolya-rm Dec 19, 2025
dccbd37
Updated the countChar(string, char) function logic for correct work i…
kolya-rm Dec 19, 2025
dca6fd2
Added a test for the repeat(str, count) function in case of repeat co…
kolya-rm Dec 19, 2025
0c5a7fe
Added a test for the repeat(str, count) function in case of repeat co…
kolya-rm Dec 19, 2025
73e2b5e
Added a test for the repeat(str, count) function in case of a negativ…
kolya-rm Dec 19, 2025
1678804
Update the implementaion of the repeat(str, count) function for corre…
kolya-rm Dec 19, 2025
bf0a77a
Added a test for the getOrdinalNumber(num) function for the case num …
kolya-rm Dec 19, 2025
bb4f50a
Added tests for the getOrdinalNumber(num) function for numbers endin…
kolya-rm Dec 19, 2025
b32ba5f
Implemented the getOrdinalNumber(num) function logic in case of numbe…
kolya-rm Dec 19, 2025
d517b61
Added tests for the getOrdinalNumber(num) function for numbers ending…
kolya-rm Dec 19, 2025
14ffc07
Implemented the getOrdinalNumber(num) function logic in case of numbe…
kolya-rm Dec 19, 2025
cc8c7c9
Added tests for the getOrdinalNumber(num) function for numbers ending…
kolya-rm Dec 19, 2025
5b5ae9d
Implemented the getOrdinalNumber(num) function logic in case of numbe…
kolya-rm Dec 19, 2025
4514213
Added tests for the getOrdinalNumber(num) function for rest numbers …
kolya-rm Dec 19, 2025
af52834
Implemented the getOrdinalNumber(num) function logic for rest numbers…
kolya-rm Dec 19, 2025
d6438d7
Added a test for the getOrdinalNumber(num) function for non numeric a…
kolya-rm Dec 19, 2025
1efb229
Implemented the getOrdinalNumber(num) function logic for non-numeric …
kolya-rm Dec 19, 2025
63aa44f
Added a test for the getOrdinalNumber(num) function for float argumen…
kolya-rm Dec 19, 2025
96117e3
Implemented the getOrdinalNumber(num) function logic for float argume…
kolya-rm Dec 19, 2025
a9143fd
Added tests for the getOrdinalNumber(num) function for non natural ar…
kolya-rm Dec 19, 2025
4615212
Implemented the getOrdinalNumber(num) function logic for non natural …
kolya-rm Dec 19, 2025
8b97833
Added answers in the find.js file in sprint 3 stretch investigate part.
kolya-rm Dec 20, 2025
058c605
In sprint 3 stretch investigate part for the function passwordValidator:
kolya-rm Dec 20, 2025
bbbd96c
In sprint 3 stretch investigate part for the function passwordValidator:
kolya-rm Dec 20, 2025
63dbae6
In sprint 3 stretch investigate part for the function passwordValidator:
kolya-rm Dec 20, 2025
b7c90ec
In sprint 3 stretch investigate part for the function passwordValidator:
kolya-rm Dec 20, 2025
a2bb392
In sprint 3 stretch investigate part for the function passwordValidator:
kolya-rm Dec 20, 2025
7a56a8b
In sprint 3 stretch investigate part for the function passwordValidator:
kolya-rm Dec 20, 2025
f4a7b81
For card validator project in sprint 3 stretch investigate part:
kolya-rm Dec 20, 2025
ee4d225
For the card validator project in sprint 3 stretch investigate part:
kolya-rm Dec 20, 2025
6942ad1
For the card validator project in sprint 3 stretch investigate part:
kolya-rm Dec 20, 2025
f050c13
For the card validator project in sprint 3 stretch investigate part:
kolya-rm Dec 20, 2025
9dd6049
For the card validator project in sprint 3 stretch investigate part:
kolya-rm Dec 20, 2025
b6f2312
For the card validator project in sprint 3 stretch investigate part:
kolya-rm Dec 20, 2025
a99ff2a
Commented logic of the cardValidator(cardNumber) function in sprint 3…
kolya-rm Dec 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
24 changes: 21 additions & 3 deletions Sprint-3/1-key-implement/1-get-angle-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,21 @@
// Then, write the next test! :) Go through this process until all the cases are implemented

function getAngleType(angle) {
if (angle === 90) return "Right angle";
// read to the end, complete line 36, then pass your test here
if (angle === 90) {
return "Right angle";
}
if (angle === 180) {
return "Straight angle";
}
if (angle < 90) {
return "Acute angle";
}
if (angle < 180) {
return "Obtuse angle";
}
if (angle < 360) {
return "Reflex angle";
}
}

// we're going to use this helper function to make our assertions easier to read
Expand Down Expand Up @@ -44,13 +57,18 @@ assertEquals(acute, "Acute angle");
// 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
// ====> 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");
60 changes: 59 additions & 1 deletion Sprint-3/1-key-implement/2-is-proper-fraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// write one test at a time, and make it pass, build your solution up methodically

function isProperFraction(numerator, denominator) {
if (numerator < denominator) return true;
return Math.abs(numerator / denominator) < 1;
}

// here's our helper again
Expand Down Expand Up @@ -41,13 +41,71 @@ assertEquals(improperFraction, false);
// 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?

// Negative numerator with absolute value greater than denominator
// Input: numerator = -5 denominator = 2
// Target output: false
// Explanation: The fraction -5/2 is a improper fraction because the absolute value of the numerator (-5) is greater than the denominator (2). The function should return false.
const negativeGreaterNumerator = isProperFraction(-5, 2);
assertEquals(negativeGreaterNumerator, false);

// Negative denominator with absolute value greater than numerator
// Input: numerator = 2 denominator = -5
// Target output: true
// Explanation: The fraction 2/-5 is a proper fraction because the numerator (2) is greater than the absolute value of the denominator (-5). The function should return true.
const negativeGreaterDenominator = isProperFraction(2, -5);
assertEquals(negativeGreaterDenominator, true);

// Negative denominator with absolute value less than numerator
// Input: numerator = 5 denominator = -2
// Target output: false
// Explanation: The fraction 5/-2 is a improper fraction because the numerator (5) is greater than the absolute value of the denominator (-2). The function should return true.
const negativeLessDenominator = isProperFraction(5, -2);
assertEquals(negativeLessDenominator, false);

// Both negative with numerator less in absolute value
// Input: numerator = -2 denominator = -5
// Target output: true
// Explanation: the fraction -2/-5 is a proper fraction because the absolute value of the numerator (-2) less than the absolute value of the denominator (-5).
const bothNegativeNumeratorLess = isProperFraction(-2, -5);
assertEquals(bothNegativeNumeratorLess, true);

// Both negative with numerator greater in absolute value
// Input: numerator = -5 denominator = -2
// Target output: false
// Explanation: the fraction -5/-2 is a improper fraction because the absolute value of the numerator(-5) greater than the absolute value of the denominator (-2).
const bothNegativeNumeratorGreater = isProperFraction(-5, -2);
assertEquals(bothNegativeNumeratorGreater, false);

// Both negative with equal values
// Input: numerator = -2 denominator = -2
// Target output: false
// Explanation: the fraction -2/-2 is a improper fraction because the numerator(-2) equal to the the denominator (-2).
const bothNegativeEqual = isProperFraction(-2, -2);
assertEquals(bothNegativeEqual, false);

// Numerator is zero
// Input: numerator = 0 denominator = 2
// Target output: true
// Explanation: the fraction 0/2 is a proper fraction because the numerator (0) less than the absolute value of the denominator (2).
const zeroNumerator = isProperFraction(0, 2);
assertEquals(zeroNumerator, true);

// Denominator is zero
// Input: numerator = 2 denominator = 0
// Target output: false
// Explanation: the fraction 2/0 is a improper fraction because the absolute value of the numerator (2) greater than the denominator (0).
const zeroDenominator = isProperFraction(2, 0);
assertEquals(zeroDenominator, false);
61 changes: 57 additions & 4 deletions Sprint-3/1-key-implement/3-get-card-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,27 @@
// 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) {
if (rank === "A") return 11;
const rank = card.slice(0, card.length - 1);
switch (rank) {
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
return Number(rank);
case "10":
case "J":
case "Q":
case "K":
return 10;
case "A":
return 11;
default:
throw new Error("Invalid card rank");
}
}

// You need to write assertions for your function to check it works in different cases
Expand All @@ -25,27 +45,60 @@ function assertEquals(actualOutput, targetOutput) {
// Given a card string in the format "A♠" (representing a card in blackjack - the last character will always be an emoji for a suit, and all characters before will be a number 2-10, or one letter of J, Q, K, A),
// When the function getCardValue is called with this card string as input,
// Then it should return the numerical card value
const aceofSpades = getCardValue("A♠");
assertEquals(aceofSpades, 11);

// Handle Number Cards (2-10):
// Given a card with a rank between "2" and "9",
// 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♥");
const fiveOfHearts = getCardValue("5♥");
const twoOfHearts = getCardValue("2♥");
const threeOfHearts = getCardValue("3♥");
const fourOfHearts = getCardValue("4♥");
const sixOfHearts = getCardValue("6♥");
const sevenOfHearts = getCardValue("7♥");
const eightOfHearts = getCardValue("8♥");
const nineOfHearts = getCardValue("9♥");
// ====> write your test here, and then add a line to pass the test in the function above
assertEquals(fiveOfHearts, 5);
assertEquals(twoOfHearts, 2);
assertEquals(threeOfHearts, 3);
assertEquals(fourOfHearts, 4);
assertEquals(sixOfHearts, 6);
assertEquals(sevenOfHearts, 7);
assertEquals(eightOfHearts, 8);
assertEquals(nineOfHearts, 9);

// 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 tenOfClubs = getCardValue("10♣");
const jackOfClubs = getCardValue("J♣");
const queenOfClubs = getCardValue("Q♣");
const kingOfClubs = getCardValue("K♣");
assertEquals(tenOfClubs, 10);
assertEquals(jackOfClubs, 10);
assertEquals(queenOfClubs, 10);
assertEquals(kingOfClubs, 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 aceOfSpades = getCardValue("A♠");
assertEquals(aceOfSpades, 11);

// 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 oneOfDiamonds = "1♦";
const twentyUnoOfDiamonds = "21♦";
const hundredOfDiamonds = "100♦";
const catOfDiamonds = "C♦";

getCardValue(oneOfDiamonds);
getCardValue(twentyUnoOfDiamonds);
getCardValue(hundredOfDiamonds);
getCardValue(catOfDiamonds);
17 changes: 15 additions & 2 deletions Sprint-3/2-mandatory-rewrite/1-get-angle-type.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
function getAngleType(angle) {
if (angle === 90) return "Right angle";
// replace with your completed function from key-implement

if (angle === 90) {
return "Right angle";
}
if (angle === 180) {
return "Straight angle";
}
if (angle < 90) {
return "Acute angle";
}
if (angle < 180) {
return "Obtuse angle";
}
if (angle < 360) {
return "Reflex angle";
}
}


Expand Down
26 changes: 13 additions & 13 deletions Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
const getAngleType = require("./1-get-angle-type");

test("should identify right angle (90°)", () => {
test("should identify right angle (angle = 90°)", () => {
expect(getAngleType(90)).toEqual("Right angle");
});

// REPLACE the comments with the tests
// make your test descriptions as clear and readable as possible

// Case 2: Identify Acute Angles:
// When the angle is less than 90 degrees,
// Then the function should return "Acute angle"
test("Should identify acute angles (angle < 90°)", () => {
expect(getAngleType(45)).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 angles (90° < angle < 180°)", () => {
expect(getAngleType(120)).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 (angle = 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 (180° < angle < 360°)", () => {
expect(getAngleType(210)).toEqual("Reflex angle");
});
3 changes: 1 addition & 2 deletions Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
function isProperFraction(numerator, denominator) {
if (numerator < denominator) return true;
// add your completed function from key-implement here
return Math.abs(numerator / denominator) < 1;
}

module.exports = isProperFraction;
44 changes: 41 additions & 3 deletions Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,46 @@ test("should return true for a proper fraction", () => {
expect(isProperFraction(2, 3)).toEqual(true);
});

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

test("Should return true for a proper negative fraction", () => {
expect(isProperFraction(-2, 3)).toEqual(true);
});

test("Should return false for equal positive numerator and denominator", () => {
expect(isProperFraction(2, 2)).toEqual(false);
});

test("Should return false for a negative improper fraction", () => {
expect(isProperFraction(-3, 2)).toEqual(false);
});

test("Should return true for a proper fraction with negative denominator", () => {
expect(isProperFraction(2, -3)).toEqual(true);
});

// Case 3: Identify Negative Fractions:
test("Should return false for an improper fraction with negative denominator", () => {
expect(isProperFraction(3, -2)).toEqual(false);
});

test("Should return true for a proper fraction with both negative parts", () => {
expect(isProperFraction(-2, -3)).toEqual(true);
});

test("Should return false false for an improper fraction with both negative parts", () => {
expect(isProperFraction(-3, -2)).toEqual(false);
});

test("Should return false for negative equal numerator and denominator", () => {
expect(isProperFraction(-2, -2)).toEqual(false);
});

test("Should return true for a fraction with zero numerator", () => {
expect(isProperFraction(0, 2)).toEqual(true);
});

// Case 4: Identify Equal Numerator and Denominator:
test("Should return false for a fraction with zero denominator", () => {
expect(isProperFraction(2, 0)).toEqual(false);
});
23 changes: 21 additions & 2 deletions Sprint-3/2-mandatory-rewrite/3-get-card-value.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
function getCardValue(card) {
// replace with your code from key-implement
return 11;
const rank = card.slice(0, card.length - 1);
switch (rank) {
case "2":
case "3":
case "4":
case "5":
case "6":
case "7":
case "8":
case "9":
case "10":
return Number(rank);
case "J":
case "Q":
case "K":
return 10;
case "A":
return 11;
default:
throw new Error("Invalid card rank");
}
}
module.exports = getCardValue;
Loading