Skip to content
Closed
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7df63de
Add description to count.js
hmkavut Jun 6, 2025
160492f
Writing to initials variable assignment value.
hmkavut Jun 6, 2025
c1a5098
Creating dir and ext variable
hmkavut Jun 6, 2025
19ff93a
Explanation of random
hmkavut Jun 7, 2025
17e9a86
fixing error in mandatory errors
hmkavut Jun 7, 2025
6bfb125
Questions in percentage-change are answered
hmkavut Jun 7, 2025
9eae4db
time format questions are answered
hmkavut Jun 9, 2025
21a6fe1
pound format questions are answered
hmkavut Jun 9, 2025
a6a69ab
strech explore questions are answered
hmkavut Jun 9, 2025
dbbdab3
First bug is fixed and interpreted
hmkavut Jun 10, 2025
d8d315c
second error is fixed and interpretted.
hmkavut Jun 10, 2025
9643e13
Third problem is fixed
hmkavut Jun 10, 2025
58cad7d
Mandatory debug session is completed.
hmkavut Jun 10, 2025
f6f291b
removed / at the end
hmkavut Jun 10, 2025
94bb164
mandatory implement part is finished
hmkavut Jun 10, 2025
81bff9c
Strech-extend is completed and removed console.log in time-format.
hmkavut Jun 14, 2025
6dd1aa9
branch id prepared for sprint 3 and first part is implemented
hmkavut Jun 25, 2025
5f4d25e
part 3 is completed
hmkavut Jun 25, 2025
476b8aa
Sprint 3 tasks are completed
hmkavut Jun 26, 2025
3d3ed47
Fixing 1-get-angle-type.js
hmkavut Jul 7, 2025
20523a5
fixing 2-is-proper-fraction and test
hmkavut Jul 7, 2025
4b83faa
fixing bugs
hmkavut Jul 7, 2025
1683209
explicitly convert is removed at repeat.js
hmkavut Jul 7, 2025
00db3f6
Throw error is added
hmkavut Jul 7, 2025
5d1653f
Functions updated with using regex
hmkavut Jul 7, 2025
66ad072
More test cases are added
hmkavut Jul 7, 2025
8916254
get-card-value part bugs are fixed
hmkavut Jul 8, 2025
11436ae
count parts is updated
hmkavut Jul 8, 2025
89f4473
Identify the ordinal numbers test cases updated
hmkavut Jul 8, 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
14 changes: 14 additions & 0 deletions Sprint-1/3-mandatory-interpret/aaa.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
for (let a = 1; a <= 9; a++) {
for (let b = 0; b <= 9; b++) {
for (let c = 1; c <= 9; c++) {
for (let d = 0; d <= 9; d++) {
let left = Math.pow(a, b) * Math.pow(c, d);
let right = parseInt(`${a}${b}${c}${d}`);

if (left === right) {
console.log(`Match found: (${a}^${b}) * (${c}^${d}) = ${left}`);
}
}
}
}
}
16 changes: 16 additions & 0 deletions Sprint-1/3-mandatory-interpret/codewars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function transposeTwoStrings(array) {
let a = "";
let no = Math.max(array[0].length, array[1].length);
for (let i = 0; i < no; i++) {
if (i < array[0].length) {
a += array[0][i];
} else a += " ";
a += " ";
if (i < array[1].length) {
a += array[1][i];
} else a += " ";
if (i < array[1].length - 1 || i < array[0].length - 1) a += "\n";
}

return a;
}
17 changes: 14 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,12 @@
// 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 === 45) return "Acute angle";
if (angle === 120) return "Obtuse angle";
if (angle === 180) return "Straight angle";
if (angle > 180 && angle <= 360) return "Reflex angle";
// read to the end, complete line 36, then pass your test here
}

// we're going to use this helper function to make our assertions easier to read
Expand Down Expand Up @@ -43,14 +47,21 @@ 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);
assertEquals(obtuse, "Obtuse angle");
// ====> write your test here, and then add a line to pass the test in the function above

// 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(181);
assertEquals(reflex, "Reflex angle");
const reflex2 = getAngleType(359);
assertEquals(reflex2, "Reflex angle");
21 changes: 20 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,9 @@
// 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;
if (Math.abs(numerator) > Math.abs(denominator)) return false;
if (Math.abs(numerator) === Math.abs(denominator)) return false;
}

// here's our helper again
Expand Down Expand Up @@ -41,13 +43,30 @@ 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?

// Equal Numerator and Denominator check:
// Input: numerator = 0, denominator = 5
// target output: true
// Explanation: The fraction 0/5 is a proper fraction, where the numerator is less than the denominator. The function should return true.
const properFraction2 = isProperFraction(0, 10);
assertEquals(properFraction2, true);

// Negative Fraction check:
// Input: numerator = 3, denominator = -6
// target output: true
// Explanation: The fraction 3/-5 is a negative fraction because the absolute value of the numerator (3) is less than the denominator (5). The function should return true.
const negativeFraction2 = isProperFraction(3, -6);
// ====> complete with your assertion
assertEquals(negativeFraction2, true);
13 changes: 12 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,11 @@
// 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;
let rank = card[0];
if (rank === "A") return 11;
if (rank === "J" || rank === "Q" || rank === "K") return 10;
if (Number(card[0]) > 0 && Number(card[0]) < 11) return Number(card[0]);
return "Invalid card rank.";
}

// You need to write assertions for your function to check it works in different cases
Expand All @@ -33,19 +37,26 @@ 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 faceofHearts = getCardValue("J♥");
assertEquals(faceofHearts, 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 aceofHearts = getCardValue("A♥");
assertEquals(aceofHearts, 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 invalidCard = getCardValue("C♥");
assertEquals(invalidCard, "Invalid card rank.");
17 changes: 6 additions & 11 deletions Sprint-3/2-mandatory-rewrite/1-get-angle-type.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
function getAngleType(angle) {
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";
}








// Don't get bogged down in this detail
// Jest uses CommonJS module syntax by default as it's quite old
// We will upgrade our approach to ES6 modules in the next course module, so for now
// We will upgrade our approach to ES6 modules in the next course module, so for now
// we have just written the CommonJS module.exports syntax for you
module.exports = getAngleType;
module.exports = getAngleType;
12 changes: 12 additions & 0 deletions Sprint-3/2-mandatory-rewrite/1-get-angle-type.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,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 right angle (75°)", () => {
expect(getAngleType(75)).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 (x>90°)", () => {
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 (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°<x<360°)", () => {
expect(getAngleType(290)).toEqual("Reflex angle");
});
5 changes: 3 additions & 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,7 @@
function isProperFraction(numerator, denominator) {
if (numerator < denominator) return true;
// add your completed function from key-implement here
if (Math.abs(numerator) < Math.abs(denominator)) return true;
if (Math.abs(numerator) > Math.abs(denominator)) return true;
if (Math.abs(numerator) === Math.abs(denominator)) return true;
}

module.exports = isProperFraction;
9 changes: 9 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,16 @@ test("should return true for a proper fraction", () => {
});

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

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

// Case 4: Identify Equal Numerator and Denominator:
test("should return true for a equal fraction", () => {
expect(isProperFraction(3, 3)).toEqual(true);
});
9 changes: 6 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,8 @@
function getCardValue(card) {
// replace with your code from key-implement
return 11;
let rank = card[0];
if (rank === "A") return 11;
if (rank === "J" || rank === "Q" || rank === "K") return 10;
if (Number(card[0]) > 0 && Number(card[0]) < 11) return Number(card[0]);
return "Invalid card rank.";
}
module.exports = getCardValue;
module.exports = getCardValue;
22 changes: 19 additions & 3 deletions Sprint-3/2-mandatory-rewrite/3-get-card-value.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
const getCardValue = require("./3-get-card-value");

test("should return 11 for Ace of Spades", () => {
const aceofSpades = getCardValue("A♠");
expect(aceofSpades).toEqual(11);
});
const aceofSpades = getCardValue("A♠");
expect(aceofSpades).toEqual(11);
});

// Case 2: Handle Number Cards (2-10):
test("should return number for card number bw 2-10", () => {
const fiveofHearts = getCardValue("5♥");
expect(fiveofHearts).toEqual(5);
});
// Case 3: Handle Face Cards (J, Q, K):
test("should return number for face of cards", () => {
const faceofHearts = getCardValue("J♥");
expect(faceofHearts).toEqual(10);
});
// Case 4: Handle Ace (A):
test("should return number for face of cards", () => {
const aceofHearts = getCardValue("A♥");
expect(aceofHearts).toEqual(11);
});
// Case 5: Handle Invalid Cards:
test("should return number for face of cards", () => {
const invalidCard = getCardValue("C♥");
expect(invalidCard).toEqual("Invalid card rank.");
});
13 changes: 12 additions & 1 deletion Sprint-3/3-mandatory-practice/implement/count.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
function countChar(stringOfCharacters, findCharacter) {
return 5
if (!stringOfCharacters.includes(findCharacter)) {
return "No occurrence";
}

let count = 0;
for (let char of stringOfCharacters) {
if (char === findCharacter) {
count++;
}
}
return count;
}


module.exports = countChar;
6 changes: 6 additions & 0 deletions Sprint-3/3-mandatory-practice/implement/count.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ test("should count multiple occurrences of a character", () => {
// And a character char that does not exist within the case-sensitive str,
// When the function is called with these inputs,
// Then it should return 0, indicating that no occurrences of the char were found in the case-sensitive str.
test("should return there is no occurrence", () => {
const str = "aaaaa";
const char = "b";
const count = countChar(str, char);
expect(count).toEqual("No occurrence");
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
function getOrdinalNumber(num) {
return "1st";
if (num % 10 ==1 && num % 100 !=11 )
return "1st";
if (num % 10 ==2 && num % 100 !=12 )
return "2nd";
if (num % 10 ==3 && num % 100 !=13 )
return "3rd";
return "th"
}

module.exports = getOrdinalNumber;
18 changes: 18 additions & 0 deletions Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,21 @@ const getOrdinalNumber = require("./get-ordinal-number");
test("should return '1st' for 1", () => {
expect(getOrdinalNumber(1)).toEqual("1st");
});
test("should return '2nd' for 2", () => {
expect(getOrdinalNumber(2)).toEqual("2nd");
});
test("should return '3rd' for 3", () => {
expect(getOrdinalNumber(3)).toEqual("3rd");
});
test("should return 'th' for 11", () => {
expect(getOrdinalNumber(11)).toEqual("th");
});
test("should return 'th' for 12", () => {
expect(getOrdinalNumber(12)).toEqual("th");
});
test("should return 'th' for 13", () => {
expect(getOrdinalNumber(13)).toEqual("th");
});
test("should return 'th' for 4", () => {
expect(getOrdinalNumber(4)).toEqual("th");
});
16 changes: 13 additions & 3 deletions Sprint-3/3-mandatory-practice/implement/repeat.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
function repeat() {
return "hellohellohello";
function repeat(str, count) {

if (Number(count) > 1) {
let result=""
for (let i = 0; i <= count-1; i++) {
result += str;
}
return result;
}
if (count == 1) return str;
if (count == 0) return "";
return "Negative counts are not valid.";
}

module.exports = repeat;
module.exports = repeat;
Loading