diff --git a/.gitignore b/.gitignore
index bde36e530..9d6b3649e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
node_modules
.DS_Store
.vscode
+package-lock.json
**/.DS_Store
\ No newline at end of file
diff --git a/Sprint-2/1-key-errors/0.js b/Sprint-2/1-key-errors/0.js
index 653d6f5a0..194714664 100644
--- a/Sprint-2/1-key-errors/0.js
+++ b/Sprint-2/1-key-errors/0.js
@@ -1,13 +1,18 @@
// Predict and explain first...
// =============> write your prediction here
-
+// I gives us a syntax error as str declared before.
// call the function capitalise with a string input
// interpret the error message and figure out why an error is occurring
-function capitalise(str) {
- let str = `${str[0].toUpperCase()}${str.slice(1)}`;
- return str;
-}
+// function capitalise(str) {
+// let str = `${str[0].toUpperCase()}${str.slice(1)}`;
+// return str;
+// }
-// =============> write your explanation here
+// =============> write your explanation here :
+// as the variable in side the function has the same name as the function variable.
// =============> write your new code here
+function capitalise(str) {
+ return `${str[0].toUpperCase()}${str.slice(1)}`;
+}
+console.log(capitalise("abcd"));
diff --git a/Sprint-2/1-key-errors/1.js b/Sprint-2/1-key-errors/1.js
index f2d56151f..be26e66f2 100644
--- a/Sprint-2/1-key-errors/1.js
+++ b/Sprint-2/1-key-errors/1.js
@@ -1,20 +1,30 @@
// Predict and explain first...
-
-// Why will an error occur when this program runs?
+// error on line 11
+// error on line 17
+// Why will an error occur when this program runs? yes
// =============> write your prediction here
+// decimalNumber is declared before and can not be declared again.
+// console.log(decimalNumber) should be console.log(convertToPercentage)
+// Try playing computer with the example to work ot what is going on
-// Try playing computer with the example to work out what is going on
-
-function convertToPercentage(decimalNumber) {
- const decimalNumber = 0.5;
- const percentage = `${decimalNumber * 100}%`;
+// function convertToPercentage(decimalNumber) {
+// const decimalNumber = 0.5;
+// const percentage = `${decimalNumber * 100}%`;
- return percentage;
-}
+// return percentage;
+// }
-console.log(decimalNumber);
+//console.log(percentage);
// =============> write your explanation here
+// decimalNumber is declared before and can not be declared again.
+// console.log(decimalNumber) should be console.log(convertToPercentage)
// Finally, correct the code to fix the problem
// =============> write your new code here
+function convertToPercentage(decimalNumber) {
+ return `${decimalNumber * 100}%`;
+
+}
+
+console.log(convertToPercentage(0.5));
diff --git a/Sprint-2/1-key-errors/2.js b/Sprint-2/1-key-errors/2.js
index aad57f7cf..3e633b725 100644
--- a/Sprint-2/1-key-errors/2.js
+++ b/Sprint-2/1-key-errors/2.js
@@ -4,17 +4,21 @@
// this function should square any number but instead we're going to get an error
// =============> write your prediction of the error here
+// line 9 num is not defined.
-function square(3) {
- return num * num;
-}
+// function square(3) {
+// return num * num;
+//}
// =============> write the error message here
-
+// SyntaxError: Unexpected number
// =============> explain this error message here
-
+// 3 is not a variable for the function to use. It should be a variable name like num or n.
// Finally, correct the code to fix the problem
// =============> write your new code here
-
+function square(num) {
+ return num * num;
+}
+console.log(square(3));
diff --git a/Sprint-2/2-mandatory-debug/0.js b/Sprint-2/2-mandatory-debug/0.js
index b27511b41..7fcd67dfe 100644
--- a/Sprint-2/2-mandatory-debug/0.js
+++ b/Sprint-2/2-mandatory-debug/0.js
@@ -1,14 +1,20 @@
// Predict and explain first...
// =============> write your prediction here
+// it looks fine.
-function multiply(a, b) {
- console.log(a * b);
-}
+// function multiply(a, b) {
+// console.log(a * b);
+//}
-console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
+// console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
// =============> write your explanation here
-
+// It misses the return value of multiply function.
// Finally, correct the code to fix the problem
// =============> write your new code here
+function multiply(a, b) {
+ return a * b;
+}
+
+console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
\ No newline at end of file
diff --git a/Sprint-2/2-mandatory-debug/1.js b/Sprint-2/2-mandatory-debug/1.js
index 37cedfbcf..6147695e4 100644
--- a/Sprint-2/2-mandatory-debug/1.js
+++ b/Sprint-2/2-mandatory-debug/1.js
@@ -1,13 +1,19 @@
// Predict and explain first...
// =============> write your prediction here
+// there is an error on line 5 and 6
+//function sum(a, b) {
+// //return;
+// a + b;
+// }
-function sum(a, b) {
- return;
- a + b;
-}
-
-console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
+// console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
// =============> write your explanation here
+//the return statement is not returning any value. a+b mentioned after return.
// Finally, correct the code to fix the problem
// =============> write your new code here
+function sum(a, b) {
+ return a + b;
+}
+
+console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
\ No newline at end of file
diff --git a/Sprint-2/2-mandatory-debug/2.js b/Sprint-2/2-mandatory-debug/2.js
index 57d3f5dc3..986d3753b 100644
--- a/Sprint-2/2-mandatory-debug/2.js
+++ b/Sprint-2/2-mandatory-debug/2.js
@@ -2,23 +2,35 @@
// Predict the output of the following code:
// =============> Write your prediction here
+// the result will be 3
+// const num = 103;
-const num = 103;
+// function getLastDigit() {
+// return num.toString().slice(-1);
+// }
-function getLastDigit() {
- return num.toString().slice(-1);
-}
-
-console.log(`The last digit of 42 is ${getLastDigit(42)}`);
-console.log(`The last digit of 105 is ${getLastDigit(105)}`);
-console.log(`The last digit of 806 is ${getLastDigit(806)}`);
+// console.log(`The last digit of 42 is ${getLastDigit(42)}`);
+// console.log(`The last digit of 105 is ${getLastDigit(105)}`);
+// console.log(`The last digit of 806 is ${getLastDigit(806)}`);
// Now run the code and compare the output to your prediction
// =============> write the output here
+//The last digit of 42 is 3
+// The last digit of 105 is 3
+// The last digit of 806 is 3
// Explain why the output is the way it is
// =============> write your explanation here
+// because num is defined as 103 and not taking any input from the function parameter.
// Finally, correct the code to fix the problem
// =============> write your new code here
+function getLastDigit(num) {
+ return num.toString().slice(-1);
+}
+
+console.log(`The last digit of 42 is ${getLastDigit(42)}`);
+console.log(`The last digit of 105 is ${getLastDigit(105)}`);
+console.log(`The last digit of 806 is ${getLastDigit(806)}`);
// This program should tell the user the last digit of each number.
// Explain why getLastDigit is not working properly - correct the problem
+// because num is defined as 103 and not taking any input from the function parameter.
\ No newline at end of file
diff --git a/Sprint-2/3-mandatory-implement/1-bmi.js b/Sprint-2/3-mandatory-implement/1-bmi.js
index 17b1cbde1..a88f4fa2e 100644
--- a/Sprint-2/3-mandatory-implement/1-bmi.js
+++ b/Sprint-2/3-mandatory-implement/1-bmi.js
@@ -16,4 +16,7 @@
function calculateBMI(weight, height) {
// return the BMI of someone based off their weight and height
-}
\ No newline at end of file
+ const bmi = weight / (height * height);
+ return bmi.toFixed(1);
+}
+console.log(`The BMI of a person weighing 70kg and 1.73m tall is ${calculateBMI(70, 1.73)}`);
\ No newline at end of file
diff --git a/Sprint-2/3-mandatory-implement/2-cases.js b/Sprint-2/3-mandatory-implement/2-cases.js
index 5b0ef77ad..07274a51f 100644
--- a/Sprint-2/3-mandatory-implement/2-cases.js
+++ b/Sprint-2/3-mandatory-implement/2-cases.js
@@ -14,3 +14,8 @@
// You will need to come up with an appropriate name for the function
// Use the MDN string documentation to help you find a solution
// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
+function toUpperSnakeCase(str) {
+
+ return str.toUpperCase().replace(/ /g, '_');
+}
+console.log(toUpperSnakeCase("it's done!"));
\ No newline at end of file
diff --git a/Sprint-2/3-mandatory-implement/3-to-pounds.js b/Sprint-2/3-mandatory-implement/3-to-pounds.js
index 6265a1a70..5e2fdf1b7 100644
--- a/Sprint-2/3-mandatory-implement/3-to-pounds.js
+++ b/Sprint-2/3-mandatory-implement/3-to-pounds.js
@@ -4,3 +4,25 @@
// You will need to declare a function called toPounds with an appropriately named parameter.
// You should call this function a number of times to check it works for different inputs
+
+function toPounds(penceString) {
+ const penceStringWithoutTrailingP = penceString.substring(
+ 0,
+ penceString.length - 1
+ );
+ const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
+ const pounds = paddedPenceNumberString.substring(
+ 0,
+ paddedPenceNumberString.length - 2
+ );
+ const pence = paddedPenceNumberString
+ .substring(paddedPenceNumberString.length - 2)
+ .padEnd(2, "0");
+
+ return `£${pounds}.${pence}`;
+}
+console.log(toPounds("399p"));
+console.log(toPounds("50p"));
+console.log(toPounds("5p"));
+console.log(toPounds("0p"));
+console.log(toPounds("12345p"));
diff --git a/Sprint-2/4-mandatory-interpret/time-format.js b/Sprint-2/4-mandatory-interpret/time-format.js
index 7c98eb0e8..8afb1df79 100644
--- a/Sprint-2/4-mandatory-interpret/time-format.js
+++ b/Sprint-2/4-mandatory-interpret/time-format.js
@@ -11,6 +11,7 @@ function formatTimeDisplay(seconds) {
return `${pad(totalHours)}:${pad(remainingMinutes)}:${pad(remainingSeconds)}`;
}
+
// You will need to play computer with this example - use the Python Visualiser https://pythontutor.com/visualize.html#mode=edit
// to help you answer these questions
@@ -18,17 +19,20 @@ function formatTimeDisplay(seconds) {
// a) When formatTimeDisplay is called how many times will pad be called?
// =============> write your answer here
+// 3 times
// Call formatTimeDisplay with an input of 61, now answer the following:
+console.log(formatTimeDisplay(61));
// b) What is the value assigned to num when pad is called for the first time?
// =============> write your answer here
-
+// 0
// c) What is the return value of pad is called for the first time?
// =============> write your answer here
-
+// "00"
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
// =============> write your answer here
-
+// 1, because remainingSeconds is 1 when pad is called for the last time.
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
// =============> write your answer here
+// "01", because pad adds a leading zero to single digit numbers.
\ No newline at end of file
diff --git a/Sprint-2/5-stretch-extend/format-time.js b/Sprint-2/5-stretch-extend/format-time.js
index 32a32e66b..970f590fa 100644
--- a/Sprint-2/5-stretch-extend/format-time.js
+++ b/Sprint-2/5-stretch-extend/format-time.js
@@ -2,24 +2,42 @@
// Make sure to do the prep before you do the coursework
// Your task is to write tests for as many different groups of input data or edge cases as you can, and fix any bugs you find.
+
+
function formatAs12HourClock(time) {
- const hours = Number(time.slice(0, 2));
- if (hours > 12) {
- return `${hours - 12}:00 pm`;
+
+if (!/^\d{2}:\d{2}$/.test(time)) {
+ return "Invalid time format";
+ }
+
+const hours = Number(time.slice(0, 2));
+const minutes = Number(time.slice(3, 5));
+if (hours < 0 || hours > 23 || minutes < 0 || minutes > 59) {
+ return "Invalid time range";
}
- return `${time} am`;
-}
+ let period = "am";
+ let displayHours = hours;
-const currentOutput = formatAs12HourClock("08:00");
-const targetOutput = "08:00 am";
-console.assert(
- currentOutput === targetOutput,
- `current output: ${currentOutput}, target output: ${targetOutput}`
-);
+ if (hours === 0) {
+ displayHours = 12; // midnight
+ } else if (hours === 12) {
+ period = "pm"; // noon
+ } else if (hours > 12) {
+ displayHours = hours - 12;
+ period = "pm";
+ }
+ const formattedHours = String(displayHours).padStart(2, "0");
+ const formattedMinutes = String(minutes).padStart(2, "0");
+ return `${formattedHours}:${formattedMinutes} ${period}`;
+}
+console.log(formatAs12HourClock("00:00"));
-const currentOutput2 = formatAs12HourClock("23:00");
-const targetOutput2 = "11:00 pm";
-console.assert(
- currentOutput2 === targetOutput2,
- `current output: ${currentOutput2}, target output: ${targetOutput2}`
-);
+console.assert(formatAs12HourClock("00:00") === "12:00 am", "Midnight");
+console.assert(formatAs12HourClock("12:00") === "12:00 pm", "Noon");
+console.assert(formatAs12HourClock("08:30") === "08:30 am", "Morning");
+console.assert(formatAs12HourClock("15:45") === "03:45 pm", "Afternoon");
+console.assert(formatAs12HourClock("23:59") === "11:59 pm", "Late night");
+console.assert(formatAs12HourClock("24:00") === "Invalid time range", "Hour too high");
+console.assert(formatAs12HourClock("12:60") === "Invalid time range", "Minute too high");
+console.assert(formatAs12HourClock("8:7") === "Invalid time format", "Wrong format");
+console.assert(formatAs12HourClock("hello") === "Invalid time format", "Not a time");
\ No newline at end of file
diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js
index ca1dfe7f2..3d9123b03 100644
--- a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js
+++ b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js
@@ -11,8 +11,22 @@ 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.
+
+ 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.
@@ -50,14 +64,20 @@ 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
\ No newline at end of file
+// ====> 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");
\ No newline at end of file
diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js
index a4739af77..2aceb3160 100644
--- a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js
+++ b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js
@@ -8,9 +8,12 @@
// write one test at a time, and make it pass, build your solution up methodically
function isProperFraction(numerator, denominator) {
- if (numerator < denominator) {
+ if (Math.abs(numerator) < Math.abs(denominator)) {
return true;
}
+ else if (numerator >= denominator) {
+ return false;
+ }
}
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -31,6 +34,7 @@ function assertEquals(actualOutput, targetOutput) {
// Input: numerator = 2, denominator = 3
// target output: true
// Explanation: The fraction 2/3 is a proper fraction, where the numerator is less than the denominator. The function should return true.
+
const properFraction = isProperFraction(2, 3);
assertEquals(properFraction, true);
@@ -38,6 +42,8 @@ assertEquals(properFraction, true);
// Input: numerator = 5, denominator = 2
// target output: false
// Explanation: The fraction 5/2 is an improper fraction, where the numerator is greater than or equal to the denominator. The function should return false.
+
+
const improperFraction = isProperFraction(5, 2);
assertEquals(improperFraction, false);
@@ -45,15 +51,21 @@ assertEquals(improperFraction, false);
// Input: numerator = -4, denominator = 7
// 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?
+
+const invalidFraction = isProperFraction(0, 5);
+assertEquals(invalidFraction, true);
diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js
index 266525d1b..edf68da3d 100644
--- a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js
+++ b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js
@@ -8,11 +8,21 @@
// 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);
+
if (rank === "A") {
return 11;
}
+ else if ( 2 <= rank && rank <= 9 ){
+ return Number(rank);
+ }
+ else if (rank === "10" || rank === "J" || rank === "Q" || rank === "K") {
+ return 10;
+ }
+ else {
+ throw new Error("Invalid card rank.");
+ }
}
-
// The line below allows us to load the getCardValue function into tests in other files.
// This will be useful in the "rewrite tests with jest" step.
module.exports = getCardValue;
@@ -40,18 +50,32 @@ assertEquals(aceofSpades, 11);
// 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♦");
+const jackofClubs = getCardValue("J♣");
+const queenofHearts = getCardValue("Q♥");
+const kingofSpades = getCardValue("K♠");
+assertEquals(tenofDiamonds, 10);
+assertEquals(jackofClubs, 10);
+assertEquals(queenofHearts, 10);
+assertEquals(kingofSpades, 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);
// 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 invalidCard1 = () => getCardValue("1♠");
+assertEquals(invalidCard1 instanceof Function, true);
+
+const invalidCard2 = () => getCardValue("B♥");
+assertEquals(invalidCard2 instanceof Function, true);
\ No newline at end of file
diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js
index 4a92a3e82..0519b120a 100644
--- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js
+++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js
@@ -1,5 +1,6 @@
// This statement loads the getAngleType function you wrote in the implement directory.
// We will use the same function, but write tests for it using Jest in this file.
+//const { test } = require("picomatch");
const getAngleType = require("../implement/1-get-angle-type");
test("should identify right angle (90°)", () => {
@@ -13,14 +14,30 @@ test("should identify right angle (90°)", () => {
// When the angle is less than 90 degrees,
// Then the function should return "Acute angle"
+test("should identify acute 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 angle (>90° and <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 angle (>180° and <360°)", () => {
+ expect(getAngleType(270)).toEqual("Reflex angle");
+})
\ No newline at end of file
diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js
index caf08d15b..30a50c86d 100644
--- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js
+++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js
@@ -7,7 +7,22 @@ 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 negative proper fraction", () => (
+ expect(isProperFraction(-4,7)).toEqual(true)
+));
// Case 4: Identify Equal Numerator and Denominator:
+test("should return false when numerator equals denominator", () => {
+ expect(isProperFraction(3,3)).toEqual(false);
+});
+
+// Stretch:
+// What other scenarios could you test for?
+test("should return true for negative proper fraction with negative denominator", () => {
+ expect(isProperFraction(4,-7)).toEqual(true);
+});
\ No newline at end of file
diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js
index 04418ff72..6c76f8c37 100644
--- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js
+++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js
@@ -1,5 +1,6 @@
// This statement loads the getCardValue function you wrote in the implement directory.
// We will use the same function, but write tests for it using Jest in this file.
+// const { test } = require("picomatch");
const getCardValue = require("../implement/3-get-card-value");
test("should return 11 for Ace of Spades", () => {
@@ -8,6 +9,27 @@ test("should return 11 for Ace of Spades", () => {
});
// Case 2: Handle Number Cards (2-10):
+test("should return numeric value for number cards (2-10)", () => {
+ const fiveofHearts = getCardValue("5♥");
+ expect(fiveofHearts).toEqual(5);
+});
// Case 3: Handle Face Cards (J, Q, K):
+test("should return 10 for face cards (J, Q, K) and 10", () => {
+ expect(getCardValue("10♦")).toEqual(10);
+ expect(getCardValue("J♣")).toEqual(10);
+ expect(getCardValue("Q♥")).toEqual(10);
+ expect(getCardValue("K♠")).toEqual(10);
+});
// Case 4: Handle Ace (A):
+test("should return 11 for Ace (A)", () => {
+ expect(getCardValue("A♦")).toEqual(11);
+});
// Case 5: Handle Invalid Cards:
+test("should throw an error for invalid card rank", () => {
+ expect(() => {
+ getCardValue("1♠");
+ }).toThrow("Invalid card rank.");
+ expect(() => {
+ getCardValue("B♥");
+ }).toThrow("Invalid card rank.");
+});
diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/coverage/clover.xml b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/coverage/clover.xml
new file mode 100644
index 000000000..bd796bd37
--- /dev/null
+++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/coverage/clover.xml
@@ -0,0 +1,6 @@
+
+
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+ +| File | ++ | Statements | ++ | Branches | ++ | Functions | ++ | Lines | ++ |
|---|