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
84e3bca
First 3 exercises of sprint 1 are completed.
eminakturk Jun 25, 2025
3c9fb3a
Key exercise part is done with this commit
eminakturk Jun 25, 2025
c882576
Mandatory errors 0 and 1.js is solved.
eminakturk Jun 25, 2025
8ccf3b2
Mandatory-errors part is finished.
eminakturk Jun 25, 2025
d0c0bd7
until time format is finished.
eminakturk Jun 27, 2025
721fe57
finishing touch
eminakturk Jun 27, 2025
3eff2ca
get-angle-type is sorted.
eminakturk Jul 27, 2025
0de42f1
proper fraction sorted.
eminakturk Jul 27, 2025
5d8d05c
get card value sorted.
eminakturk Jul 27, 2025
7fe2790
sprint3 coursework done.
eminakturk Jul 27, 2025
fed3a0c
Merge branch 'main' into coursework/sprint3
eminakturk Jul 27, 2025
16e88b9
Delete Sprint-1/1-key-exercises/1-count.js
eminakturk Aug 4, 2025
17f9a99
Delete Sprint-1/1-key-exercises/2-initials.js
eminakturk Aug 4, 2025
4266d77
Delete Sprint-1/1-key-exercises/3-paths.js
eminakturk Aug 4, 2025
05564df
Delete Sprint-1/1-key-exercises/4-random.js
eminakturk Aug 4, 2025
a932cb1
Delete Sprint-1/2-mandatory-errors/0.js
eminakturk Aug 4, 2025
2c47ed9
Delete Sprint-1/2-mandatory-errors/1.js
eminakturk Aug 4, 2025
1b7c8c7
Delete Sprint-1/2-mandatory-errors/2.js
eminakturk Aug 4, 2025
c95381e
Delete Sprint-1/2-mandatory-errors/3.js
eminakturk Aug 4, 2025
1fd0b02
Delete Sprint-1/2-mandatory-errors/4.js
eminakturk Aug 4, 2025
71b7003
Delete Sprint-1/3-mandatory-interpret/1-percentage-change.js
eminakturk Aug 4, 2025
0c7b105
Delete Sprint-1/3-mandatory-interpret/2-time-format.js
eminakturk Aug 4, 2025
97d27ed
Delete Sprint-1/3-mandatory-interpret/3-to-pounds.js
eminakturk Aug 4, 2025
47d5d46
the errors mentioned are fixed.
eminakturk Aug 12, 2025
2f97455
Merge branch 'coursework/sprint3' of https://github.com/eminakturk/Mo…
eminakturk Aug 12, 2025
29d0ece
Merge branch 'main' into coursework/sprint3
eminakturk Aug 13, 2025
315d99a
latest error fix.
eminakturk Aug 14, 2025
d31e82f
Merge branch 'coursework/sprint3' of https://github.com/eminakturk/Mo…
eminakturk Aug 14, 2025
cf78bda
fixes back to deleted files.
eminakturk Aug 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
48 changes: 43 additions & 5 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 === undefined || isNaN(angle)) {
return "Invalid angle: Please provide a valid number";
}

if (angle < 0 || angle > 360) {
return "Invalid angle: Angle must be between 0 and 360 degrees";
}

if (angle === 360 || angle === 0) return "Full rotation";

if (angle === 90) return "Right angle";
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";
}

// we're going to use this helper function to make our assertions easier to read
Expand Down Expand Up @@ -44,13 +57,38 @@ 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(270);
assertEquals(reflex, "Reflex angle");

// Case 6: Identify Full Rotation:
// When the angle is exactly 360 degrees or 0 degrees,
// Then the function should return "Full rotation"
const fullRotation = getAngleType(360);
assertEquals(fullRotation, "Full rotation");
const zeroAngle = getAngleType(0);
assertEquals(zeroAngle, "Full rotation");

// Case 7: Handle missing input:
// When no angle is provided,
// Then the function should return an error message
const noAngle = getAngleType();
assertEquals(noAngle, "Invalid angle: Please provide a valid number");

// Case 8: Handle invalid angle values:
// When an angle outside the valid range (0-360 degrees) is provided,
// Then the function should return an error message
const tooBig = getAngleType(361);
assertEquals(tooBig, "Invalid angle: Angle must be between 0 and 360 degrees");
const negative = getAngleType(-10);
assertEquals(negative, "Invalid angle: Angle must be between 0 and 360 degrees");
12 changes: 8 additions & 4 deletions 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,11 @@
// 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 (Math.abs(numerator) < Math.abs(denominator)) {
return true;
} else {
return false;
}
}

// here's our helper again
Expand Down Expand Up @@ -40,14 +44,14 @@ 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?
// What other scenarios could you test for?
53 changes: 52 additions & 1 deletion 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,20 @@
// 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 (!card || card.length < 2) {
throw new Error("Invalid card rank.");
}

const rank = card.slice(0, -1);

if (rank === "A") return 11;
if (rank === "J" || rank === "Q" || rank === "K" || rank === "10") return 10;

if (!isNaN(rank) && Number(rank) >= 2 && Number(rank) <= 9 && rank.length === 1) {
return Number(rank);
}

throw new Error("Invalid card rank.");
}

// You need to write assertions for your function to check it works in different cases
Expand All @@ -33,12 +46,23 @@ 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 jackofClubs = getCardValue("J♣");
assertEquals(jackofClubs, 10);

const queenofDiamonds = getCardValue("Q♦");
assertEquals(queenofDiamonds, 10);

const kingofHearts = getCardValue("K♥");
assertEquals(kingofHearts, 10);

const tenofSpades = getCardValue("10♠");
assertEquals(tenofSpades, 10);

// Handle Ace (A):
// Given a card with a rank of "A",
Expand All @@ -49,3 +73,30 @@ const fiveofHearts = getCardValue("5♥");
// 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."
try {
getCardValue("Z♠");
console.error("Error was expected but not thrown");
} catch (e) {
assertEquals(e.message, "Invalid card rank.");
}

try {
const oddValue = getCardValue("345♠");
console.error("Error was expected but not thrown for '345♠'");
} catch (e) {
assertEquals(e.message, "Invalid card rank.");
}

try {
const onlySuit = getCardValue("♠");
console.error("Error was expected but not thrown for '♠'");
} catch (e) {
assertEquals(e.message, "Invalid card rank.");
}

try {
const oneHundred = getCardValue("100♠");
console.error("Error was expected but not thrown for '100♠'");
} catch (e) {
assertEquals(e.message, "Invalid card rank.");
}
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 === undefined || isNaN(angle)) {
return "Invalid angle: Please provide a valid number";
}

if (angle < 0 || angle > 360) {
return "Invalid angle: Angle must be between 0 and 360 degrees";
}

if (angle === 360 || angle === 0) return "Full rotation";
if (angle === 90) return "Right angle";
// replace with your completed function from key-implement

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";

return "Invalid angle: Please provide a valid number";
}


Expand Down
37 changes: 31 additions & 6 deletions Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,46 @@ test("should identify right 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 (less than 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 (greater than 90° and less than 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 (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 angles (greater than 180° and less than 360°)", () => {
expect(getAngleType(270)).toEqual("Reflex angle");
});

test("should identify full rotation (0° or 360°)", () => {
expect(getAngleType(360)).toEqual("Full rotation");
expect(getAngleType(0)).toEqual("Full rotation");
});

test("should handle undefined angle value", () => {
expect(getAngleType()).toEqual("Invalid angle: Please provide a valid number");
});

test("should handle angle values outside the valid range", () => {
expect(getAngleType(361)).toEqual("Invalid angle: Angle must be between 0 and 360 degrees");
expect(getAngleType(-10)).toEqual("Invalid angle: Angle must be between 0 and 360 degrees");
});

test("should handle edge case inputs that might bypass initial checks", () => {
expect(getAngleType(NaN)).toEqual("Invalid angle: Please provide a valid number");
expect(getAngleType(null)).toEqual("Acute angle");
});
13 changes: 10 additions & 3 deletions Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
function isProperFraction(numerator, denominator) {
if (numerator < denominator) return true;
// add your completed function from key-implement here
if (denominator === 0) {
return false;
}

if (Math.abs(numerator) < Math.abs(denominator)) {
return true;
} else {
return false;
}
}

module.exports = isProperFraction;
module.exports = isProperFraction;
14 changes: 14 additions & 0 deletions Sprint-3/2-mandatory-rewrite/2-is-proper-fraction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,21 @@ test("should return true for a proper fraction", () => {
});

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

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

// Case 4: Identify Equal Numerator and Denominator:
test("should return false when numerator and denominator are equal", () => {
expect(isProperFraction(3, 3)).toEqual(false);
});

test("should return false when denominator is zero", () => {
expect(isProperFraction(0, 0)).toEqual(false);
expect(isProperFraction(5, 0)).toEqual(false);
});
14 changes: 11 additions & 3 deletions Sprint-3/2-mandatory-rewrite/3-get-card-value.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
function getCardValue(card) {
// replace with your code from key-implement
return 11;
if (!card || card.length < 2) {
throw new Error("Invalid card rank.");
}

const rank = card.slice(0, -1);
if (rank === "A") return 11;
if (rank === "J" || rank === "Q" || rank === "K" || rank === "10") return 10;
if (!isNaN(rank) && Number(rank) >= 2 && Number(rank) <= 9) return Number(rank);
throw new Error("Invalid card rank.");
}
module.exports = getCardValue;

module.exports = getCardValue;
31 changes: 30 additions & 1 deletion Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js

Choose a reason for hiding this comment

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

I suggest adding tests for these edge cases:

  • card value: 345
  • card value: ♠
  • card value: 100♠

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,38 @@ const getCardValue = require("./3-get-card-value");
test("should return 11 for Ace of Spades", () => {
const aceofSpades = getCardValue("A♠");
expect(aceofSpades).toEqual(11);
});
});

// Case 2: Handle Number Cards (2-10):
test("should return correct number for number cards", () => {
expect(getCardValue("5♥")).toEqual(5);
expect(getCardValue("10♦")).toEqual(10);
});

// Case 3: Handle Face Cards (J, Q, K):
test("should return 10 for face cards J, Q, K", () => {
expect(getCardValue("J♣")).toEqual(10);
expect(getCardValue("Q♦")).toEqual(10);
expect(getCardValue("K♥")).toEqual(10);
});

// Case 4: Handle Ace (A):
// (Already tested above with Ace of Spades)

// Case 5: Handle Invalid Cards:
test("should throw error for invalid cards", () => {

Choose a reason for hiding this comment

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

Can you review the test at line 25? The assertion fails.

expect(() => getCardValue("Z♠")).toThrow("Invalid card rank.");
expect(() => getCardValue("1♠")).toThrow("Invalid card rank.");
});

test("should throw error for multi-digit number (other than 10)", () => {
expect(() => getCardValue("345♠")).toThrow("Invalid card rank.");
});

test("should throw error for only suit (no rank)", () => {
expect(() => getCardValue("♠")).toThrow("Invalid card rank.");
});

test("should throw error for numbers out of range", () => {
expect(() => getCardValue("100♠")).toThrow("Invalid card rank.");
});
8 changes: 6 additions & 2 deletions Sprint-3/3-mandatory-practice/implement/count.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
function countChar(stringOfCharacters, findCharacter) {
return 5
let count = 0;
for (let char of stringOfCharacters) {
if (char === findCharacter) count++;
}
return count;
}

module.exports = countChar;
module.exports = countChar;
Loading
Loading