Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
82d3c7a
1-key-implementation. The environment and the first test
DraftRoman Dec 10, 2025
d9239ff
critical issue (Full rotation error)
DraftRoman Dec 10, 2025
495ca74
1-key-implementation 1 exercise
DraftRoman Dec 10, 2025
afb0c15
Codewars
DraftRoman Dec 15, 2025
2bb7f08
fix(statement) / added test.js
DraftRoman Dec 15, 2025
fa4d682
Stretch tests and found an edge case which has to be fixed
DraftRoman Dec 16, 2025
9b87764
Complete with the second exercise in 1-key
DraftRoman Dec 16, 2025
8d94f33
fix (A case)
DraftRoman Dec 16, 2025
473e8d8
Handle Face Cards (J, Q, K)
DraftRoman Dec 16, 2025
be402a6
edges cases for second and third exercises
DraftRoman Dec 16, 2025
dd62bbc
Updated 3-get-card-value
DraftRoman Dec 16, 2025
9e41d05
2-mandatory-rewrite copied test and added edges cases
DraftRoman Dec 16, 2025
d0365f9
2-is-proper-fraction tests for every cases
DraftRoman Dec 16, 2025
f5134d7
3-get-card-value.js exercise 3
DraftRoman Dec 16, 2025
6aa5cce
fix(count.js) tests
DraftRoman Dec 16, 2025
3d0d8cd
Added Input Validation
DraftRoman Dec 16, 2025
9d75e8e
get-ordinal-number (created tests)
DraftRoman Dec 17, 2025
de514f5
Updated the tests
DraftRoman Dec 17, 2025
8671464
configured the process logic
DraftRoman Dec 17, 2025
679096d
fix(not integer input) and moved input validation
DraftRoman Dec 17, 2025
3358580
optimization of the code
DraftRoman Dec 17, 2025
75a9cc7
setted basic test for repeat .js
DraftRoman Dec 17, 2025
b068ce3
wrote the logic for the function / added test for not a number
DraftRoman Dec 18, 2025
d316947
fixed(module.export)
DraftRoman Dec 18, 2025
25b726f
4-stretch-find. Questions
DraftRoman Dec 19, 2025
4b3507b
4-Password validation (5 characters / A-Z / a-z)
DraftRoman Dec 19, 2025
affdae6
4-stretch password validation / changed the tests
DraftRoman Dec 20, 2025
ab4b879
added validation to special character and privies password
DraftRoman Dec 21, 2025
3583c4e
Were added tests for previous passwords
DraftRoman Dec 21, 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
28 changes: 22 additions & 6 deletions Sprint-3/1-key-implement/1-get-angle-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
// Write the code to pass the test
// 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
}
function getAngleType(angle) {
if (angle < 90) return "Acute angle";
else if (angle === 90) return "Right angle";
else if (angle > 90 && angle < 180) return "Obtuse angle";
else if (angle === 180) return "Straight angle";
else if (angle > 180 && angle < 360) return "Reflex angle";
else if (angle === 360) return "Full rotation";
}
module.exports = { getAngleType };

// we're going to use this helper function to make our assertions easier to read
// if the actual output matches the target output, the test will pass
Expand Down Expand Up @@ -42,15 +47,26 @@ assertEquals(acute, "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"
const obtuse = getAngleType(120);
// ====> write your test here, and then add a line to pass the test in the function above
const obtuse = getAngleType(120);
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(270);
assertEquals(reflex, "Reflex angle");
// Case 6: Identify Full Rotation:
// When the angle is exactly 360 degrees,
// Then the function should return "Full rotation"
// ====> write your test here, and then add a line to pass the test in the function above
const fullRotation = getAngleType(360);
assertEquals(fullRotation, "Full rotation");
27 changes: 27 additions & 0 deletions Sprint-3/1-key-implement/1-get-angle-type.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { getAngleType } = require("./1-get-angle-type");

describe("getAngleType", () => {
test("Case 1: identifies Right Angles", () => {
expect(getAngleType(90)).toBe("Right angle");
});

test("Case 2: identifies Acute Angles", () => {
expect(getAngleType(45)).toBe("Acute angle");
});

test("Case 3: identifies Obtuse Angles", () => {
expect(getAngleType(120)).toBe("Obtuse angle");
});

test("Case 4: identifies Straight Angles", () => {
expect(getAngleType(180)).toBe("Straight angle");
});

test("Case 5: identifies Reflex Angles", () => {
expect(getAngleType(270)).toBe("Reflex angle");
});

test("Case 6: identifies Full Rotation", () => {
expect(getAngleType(360)).toBe("Full rotation");
});
});
24 changes: 23 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,8 +8,16 @@
// write one test at a time, and make it pass, build your solution up methodically

function isProperFraction(numerator, denominator) {
if (numerator < denominator) return true;
if (numerator < 0 && denominator < 0) {
numerator = -numerator;
denominator = -denominator;
}
if (denominator <= 0) return false;
if (numerator < denominator) return true;
else return false;
}
module.exports = { isProperFraction };


// here's our helper again
function assertEquals(actualOutput, targetOutput) {
Expand Down Expand Up @@ -51,3 +59,17 @@ const equalFraction = isProperFraction(3, 3);

// Stretch:
// What other scenarios could you test for?
const stretchFraction1 = isProperFraction(0, 5);

const stretchFraction2 = isProperFraction(3, -4);

const stretchFraction3 = isProperFraction(-2, -3);
// ====> complete with your assertions
assertEquals(negativeFraction, true);
assertEquals(equalFraction, false);
assertEquals(stretchFraction1, true);
assertEquals(stretchFraction2, false);
assertEquals(stretchFraction3, true);
const stretchFraction4 = isProperFraction(3, 0);
assertEquals(stretchFraction4, false);

31 changes: 31 additions & 0 deletions Sprint-3/1-key-implement/2-is-proper-fraction.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const { isProperFraction } = require("./2-is-proper-fraction");

describe("isProperFraction", () => {
test("Case 1: identifies proper fractions", () => {
expect(isProperFraction(2, 3)).toBe(true);
});
test("Case 2: identifies improper fractions", () => {
expect(isProperFraction(5, 2)).toBe(false);
});
test("Case 3: identifies negative proper fractions", () => {
expect(isProperFraction(-4, 7)).toBe(true);
});
test("Case 4: identifies equal numerator and denominator as improper", () => {
expect(isProperFraction(3, 3)).toBe(false);
});
// Stretch tests can be added here
test("Stretch Case 1: identifies zero numerator as proper fraction", () => {
expect(isProperFraction(0, 5)).toBe(true);
});
test("Stretch Case 2: identifies negative denominator as improper fraction", () => {
expect(isProperFraction(3, -4)).toBe(false);
});
test("Stretch Case 3: identifies both negative numerator and denominator as proper fraction", () => {
expect(isProperFraction(-2, -3)).toBe(true);
});
test("Stretch Case 4: identifies zero denominator as improper fraction", () => {
expect(isProperFraction(3, 0)).toBe(false);
});

});

19 changes: 16 additions & 3 deletions Sprint-3/1-key-implement/3-get-card-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
// complete the rest of the tests and cases
// 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;
}
if (card.charAt(0) === "A") return 11;
else if ((card.charAt(0) === "K") || (card.charAt(0) === "Q") || (card.charAt(0) === "J") || (card.slice(0, 2) === "10")) return 10;
else if (parseInt(card.charAt(0)) >= 2 && parseInt(card.charAt(0)) <= 9) return parseInt(card.charAt(0));
else throw new Error("Invalid card rank.");

}
module.exports = { getCardValue };
// You need to write assertions for your function to check it works in different cases
// we're going to use this helper function to make our assertions easier to read
// if the actual output matches the target output, the test will pass
Expand All @@ -33,13 +38,21 @@ 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♥");
assertEquals(fiveofHearts, 5);
// ====> write your test here, and then add a line to pass the test in the function above

// 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 kingofDiamonds = getCardValue("K♦");
const queenofClubs = getCardValue("Q♣");
const jackofSpades = getCardValue("J♠");
const tenofHearts = getCardValue("10♥");
assertEquals(kingofDiamonds, 10);
assertEquals(queenofClubs, 10);
assertEquals(jackofSpades, 10);
assertEquals(tenofHearts, 10);
// Handle Ace (A):
// Given a card with a rank of "A",
// When the function is called with an Ace,
Expand Down
27 changes: 27 additions & 0 deletions Sprint-3/1-key-implement/3-get-card-value.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const {getCardValue} = require("./3-get-card-value");

describe("getCardValue", () => {
test("Case 1: handles Ace (A)", () => {
expect(getCardValue("A♠")).toBe(11);
});
test("Case 2: handles Number Cards (2-10)", () => {
expect(getCardValue("5♥")).toBe(5);
});
test("Case 3: handles Face Cards (J, Q, K)", () => {
expect(getCardValue("K♦")).toBe(10);
expect(getCardValue("Q♣")).toBe(10);
expect(getCardValue("J♠")).toBe(10);
expect(getCardValue("10♥")).toBe(10);
});
test("Stretch Case: handles Invalid Cards", () => {
expect(() => {
getCardValue("1♠");
}).toThrow("Invalid card rank.");
});
test("Stretch Case: handles Invalid Cards with letter", () => {
expect(() => {
getCardValue("X♠");
}).toThrow("Invalid card rank.");
});

});
Loading