Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
c3cc796
refactor: update formatAs12HourClock function to improve time parsing…
moses77-boop Oct 3, 2026
b03e0fb
refactor: update test syntax to use arrow functions for consistency
moses77-boop Oct 3, 2026
05e8ef3
fix: ensure formatAs12HourClock function exports correctly
moses77-boop Oct 3, 2026
1544b38
test: add test case for converting midnight time
moses77-boop Oct 3, 2026
8230a0e
refactor: improve time conversion logic and enhance test cases for cl…
moses77-boop Oct 3, 2026
ead95df
fix: correct return statement in formatAs12HourClock function for acc…
moses77-boop Oct 3, 2026
19e10f5
test: add test case for converting the last minute before noon
moses77-boop Oct 3, 2026
15938a2
test: add test case for converting exact noon to pm
moses77-boop Oct 3, 2026
8acdeaa
test: add test case for converting time just after noon
moses77-boop Oct 3, 2026
a7d1115
fix: add missing newline at end of timeConverter.test.js
moses77-boop Oct 3, 2026
ee8f85b
fix: remove space before am/pm in time formatting and clean up test c…
moses77-boop Oct 3, 2026
f93cd35
fix: remove space before period in time formatting
moses77-boop Oct 3, 2026
59863c5
test: add test case for converting late evening hour
moses77-boop Oct 3, 2026
c6ed571
test: add test case for converting last minute of the day
moses77-boop Oct 3, 2026
ced1c53
fix: correct expected output for first afternoon hour test case
moses77-boop Oct 3, 2026
9f0876f
test: add test case for preserving minutes with leading zero
moses77-boop Oct 3, 2026
03c860b
test: update console log to test formatting for 8:00 AM
moses77-boop Oct 3, 2026
42d563c
test: add test case for preserving non-zero minutes
moses77-boop Oct 3, 2026
91ccb0c
test: update console log to test formatting for 8:40 AM
moses77-boop Oct 3, 2026
472364d
Remove commented-out code from time formatting function
moses77-boop Oct 4, 2026
5b48a96
Remove console log from time formatting function
moses77-boop Oct 4, 2026
8a74015
Add jsconfig.json for TypeScript configuration
moses77-boop Oct 4, 2026
27919c8
Format code and improve readability
moses77-boop Oct 4, 2026
fa688b1
Simplify period determination and improve formatting
moses77-boop Oct 5, 2026
5d58269
Refactor display hour calculation for 12-hour clock format
moses77-boop Oct 5, 2026
f9fac2a
Remove jsconfig.json and clean up package.json by deleting devDepende…
moses77-boop Oct 5, 2026
aba0771
Refactor folders to match main
moses77-boop Oct 5, 2026
dc99174
Add test case for classifying acute angles
moses77-boop Oct 8, 2026
ca9a48e
Add test case for classifying acute angles at 1 degree
moses77-boop Oct 8, 2026
e9127dd
Add test case for classifying acute angles at 89 degrees
moses77-boop Oct 8, 2026
965d13c
Implement angle classification function for acute and right angles
moses77-boop Oct 8, 2026
f95598e
Add test cases for classifying obtuse angles
moses77-boop Oct 8, 2026
727a787
add angle classification logic for obtuse angles
moses77-boop Oct 8, 2026
fc10ee8
Add test case for classifying straight angles
moses77-boop Oct 8, 2026
a54dbf3
add angle classification logic for straight angle
moses77-boop Oct 8, 2026
59841f3
Add test cases for classifying reflex angles
moses77-boop Oct 8, 2026
985fc65
add angle classification logic for reflex angle
moses77-boop Oct 8, 2026
e34c680
Add test cases for classifying invalid angles
moses77-boop Oct 8, 2026
d044803
Fix logic for invalid angle classification
moses77-boop Oct 8, 2026
dcbaa8a
Fix typo in angle classification for right angle
moses77-boop Oct 8, 2026
cafa444
Fix logic for reflex angle classification
moses77-boop Oct 8, 2026
c864dae
Implement isProperFraction function to evaluate proper fractions
moses77-boop Oct 8, 2026
25a95f7
Fix return values in isProperFraction function to boolean type and up…
moses77-boop Oct 8, 2026
a494567
Add test case for negative numerator in isProperFraction function
moses77-boop Oct 8, 2026
f9957fb
Add test case for negative denominator in isProperFraction function
moses77-boop Oct 8, 2026
8ad8453
Add test case for negative numerator and denominator in isProperFract…
moses77-boop Oct 8, 2026
5833229
Add test case for improper fractions in isProperFraction function
moses77-boop Oct 8, 2026
6735c73
Add test case for basic improper fraction in isProperFraction function
moses77-boop Oct 8, 2026
e2cac11
Add test case for equal numerator and denominator in isProperFraction…
moses77-boop Oct 8, 2026
ebfa5cc
Add test case for zero denominator in isProperFraction function
moses77-boop Oct 8, 2026
157c520
Add test case for negative numerator in isProperFraction function
moses77-boop Oct 8, 2026
68c5501
Add test case for negative denominator in isProperFraction function
moses77-boop Oct 8, 2026
7df31ab
Add test case for negative numerator and denominator in isProperFract…
moses77-boop Oct 8, 2026
39c47a2
Implement valid suits array in getCardValue function
moses77-boop Oct 8, 2026
ecd96e6
Fix syntax error in validSuits array in getCardValue function
moses77-boop Oct 8, 2026
7efe47c
Add numberRanks array to getCardValue function
moses77-boop Oct 8, 2026
f85638b
Add faceRanks array to getCardValue function
moses77-boop Oct 8, 2026
d37ed99
Add faceRanks array to getCardValue function
moses77-boop Oct 8, 2026
e1ddceb
Add error handling for invalid card format in getCardValue function
moses77-boop Oct 8, 2026
fcf852f
add initial validation for card input in getCardValue function
moses77-boop Oct 8, 2026
c1b599d
Add suit and rank extraction with validation in getCardValue function
moses77-boop Oct 8, 2026
7567f28
Implement handling for Ace rank in getCardValue function
moses77-boop Oct 8, 2026
93b333a
implement handling for faceRanks to return 10 for face cards
moses77-boop Oct 8, 2026
1348019
Refactor getCardValue function to ensure proper handling of number ra…
moses77-boop Oct 8, 2026
e7cfd7b
Fix suit representation in getCardValue function to use Unicode chara…
moses77-boop Oct 8, 2026
cd4dc16
Comment out console log statement for getCardValue function
moses77-boop Oct 8, 2026
d60f2bd
Add test case for Ace card value
moses77-boop Oct 8, 2026
f38db7f
Add test cases for face cards to ensure they return a value of 10
moses77-boop Oct 8, 2026
c25755d
Add test case for number cards 2 to 10 to verify correct value returns
moses77-boop Oct 8, 2026
f3c9bda
Fix formatting in number card test for consistency
moses77-boop Oct 8, 2026
84f32b8
Add test for valid double-digit '10' card to ensure correct value ret…
moses77-boop Oct 8, 2026
ea302ed
Add tests to ensure all four suits are accepted
moses77-boop Oct 8, 2026
78d0ff4
Add test for missing suit to validate error handling
moses77-boop Oct 8, 2026
6635d24
Add test for missing ranks to validate error handling
moses77-boop Oct 8, 2026
700c2b9
Fix tests for missing suit and ranks to ensure proper error handling
moses77-boop Oct 8, 2026
c06b701
Add test for empty strings to validate error handling
moses77-boop Oct 8, 2026
bc54e01
Add test for out-of-range number ranks to validate error handling
moses77-boop Oct 8, 2026
47797b5
Add test for unknown suit to validate error handling
moses77-boop Oct 8, 2026
a6231b0
Add test for lowercase ranks to validate error handling
moses77-boop Oct 8, 2026
20e286a
Add test for suit before rank to validate error handling
moses77-boop Oct 8, 2026
d91a6cb
Add tests for extra characters, spaces, and non-string inputs to vali…
moses77-boop Oct 8, 2026
2052992
Remove commented-out console log for getCardValue function
moses77-boop Oct 8, 2026
e021e17
Remove formatAs12HourClock function and its tests due to refactoring
moses77-boop Oct 8, 2026
5c7ee79
Add formatAs12HourClock function and corresponding tests for time con…
moses77-boop Oct 8, 2026
1c195d7
Remove formatAs12HourClock function and its tests due to refactoring
moses77-boop Oct 8, 2026
7a4a0c7
Implement formatAs12HourClock function with comprehensive tests for t…
moses77-boop Oct 8, 2026
e313bdc
Remove formatAs12HourClock function and its tests due to refactoring
moses77-boop Oct 8, 2026
c6ae2f7
Delete format-clock-edge-cases/timeConverter.js
moses77-boop Oct 8, 2026
32535c7
Add formatAs12HourClock function and comprehensive tests for edge cases
moses77-boop Oct 8, 2026
0ea7ccc
Merge branch 'coursework/sprint-3-implement-and-rewrite' of https://g…
moses77-boop Oct 8, 2026
46a0c2e
Complete Sprint 3 implement and rewrite exercises
moses77-boop Oct 8, 2026
c836b42
Merge remote-tracking branch 'origin/coursework/sprint-3-implement-an…
moses77-boop Oct 8, 2026
072555c
Delete format-clock-edge-cases/timeConverter.test.js
moses77-boop Oct 8, 2026
6bba53a
Exclude format-clock-edge-cases from PR
moses77-boop Oct 8, 2026
1b0e5bb
Merge remote-tracking branch 'origin/coursework/sprint-3-implement-an…
moses77-boop Oct 8, 2026
d11f634
Add unit tests for time conversion in timeConverter.js
moses77-boop Oct 9, 2026
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
32 changes: 26 additions & 6 deletions format-clock-edge-cases/timeConverter.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
function formatAs12HourClock(time) {
// function formatAs12HourClock(time) {

const hours = Number(time.slice(0, 2));
// const hours = Number(time.slice(0, 2));

if (hours > 12) {
return `${hours - 12}:00 pm`;
// if (hours > 12) {
// return `${hours - 12}:00 pm`;
// }
// return `${time} am`;
// }

// export {formatAs12HourClock};

function formatAs12HourClock(time){
const [hourPart, minutePart] = time.split(":");
const hours = Number(hourPart);

let period;
if(hours < 12){
period = "am";
} else {
period = "pm";
}
return `${time} am`;
}

let displayHour = hours % 12;
if(displayHour === 0){
displayHour = 12;
}
return `${displayHour}:${minutePart}${period}`;
}
export {formatAs12HourClock};
console.log(formatAs12HourClock("08:40"))
40 changes: 35 additions & 5 deletions format-clock-edge-cases/timeConverter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,40 @@ import {formatAs12HourClock} from "./timeConverter.js";
import assert from "node:assert";
import test from "node:test";

test("correctly convert time after 12:00", function(){
assert.equal(formatAs12HourClock("23:00"), "11:00 pm");
test("correctly convert time after 12:00", () => {
assert.equal(formatAs12HourClock("23:00"), "11:00pm");
});

test("can correctly convert morning time", function() {
assert.equal(formatAs12HourClock("08:00"), "08:00 am");
});
test("converts a single-digit morning hour and drops leading zero", () => {
assert.equal(formatAs12HourClock("08:00"), "8:00am");
})
test("converts exactly to midnight", () => {
assert.equal(formatAs12HourClock("00:00"), "12:00am");
})
test("converts time just after midnight", () => {
assert.equal(formatAs12HourClock("00:30"), "12:30am");
})
test("converts the last minute before noon", () => {
assert.equal(formatAs12HourClock("11:59"), "11:59am");
})
test("converts exact noon to pm", () => {
assert.equal(formatAs12HourClock("12:00"), "12:00pm");
})
test("convert time just after noon", () => {
assert.equal(formatAs12HourClock("12:30"), "12:30pm");
})
test("converts the first afternoon hour", () => {
assert.equal(formatAs12HourClock("13:00"), "1:00pm");
})
test("converts late evening hour", () => {
assert.equal(formatAs12HourClock("23:00"), "11:00pm");
})
test("converts last minute of the day", () => {
assert.equal(formatAs12HourClock("23:59"), "11:59pm");
})
test("preserves minutes with leading zero", () => {
assert.equal(formatAs12HourClock("09:05"), "9:05am");
})
test("preserves non-zero minutes", () => {
assert.equal(formatAs12HourClock("14:45"), "2:45pm");
})
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,32 @@ test("Classifies right angles", () => {
const right = getAngleType(90);
assert.equal(right, "Right angle");
});

test("Classifies acute angles", () => {
assert.equal(getAngleType(45), "Acute angle");
assert.equal(getAngleType(1), "Acute angle");
assert.equal(getAngleType(89), "Acute angle");
});

test("Classifies obtuse angles", () => {
assert.equal(getAngleType(91), "Obtuse angle");
assert.equal(getAngleType(135), "Obtuse angle");
assert.equal(getAngleType(179), "Obtuse angle");
});

test("Classifies straight angles", () => {
assert.equal(getAngleType(180), "Straight angle");
});

test("Classifies reflex angles", () => {
assert.equal(getAngleType(181), "Reflex angle");
assert.equal(getAngleType(270), "Reflex angle");
assert.equal(getAngleType(359), "Reflex angle");
});

test("Classifies invalid angles", () => {
assert.equal(getAngleType(0), "Invalid angle");
assert.equal(getAngleType(360), "Invalid angle");
assert.equal(getAngleType(400), "Invalid angle");
assert.equal(getAngleType(-5), "Invalid angle");
})
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js";
// What combinations of numerators and denominators should you test?

test("Basic proper fraction", () => {
// Example: 1/2 is a proper fraction
assert.equal(isProperFraction(1, 2), true);
assert.equal(isProperFraction(0, 5), true);
assert.equal(isProperFraction(-1, 2), true);
assert.equal(isProperFraction(1, -2), true);
assert.equal(isProperFraction(-1, -2), true);
});

test("Basic improper fraction", () => {
assert.equal(isProperFraction(5, 2), false);
assert.equal(isProperFraction(3, 3), false);
assert.equal(isProperFraction(5, 0), false);
assert.equal(isProperFraction(-5, 2), false);
assert.equal(isProperFraction(5, -2), false);
assert.equal(isProperFraction(-5, -2), false);
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,77 @@ test("Valid single-digit card", () => {
assert.equal(getCardValue("9♠"), 9);
});

test("Ace returns 11", () => {
assert.equal(getCardValue("A♠"), 11);
});

test("Face cards return 10", () => {
assert.equal(getCardValue("J♣"), 10);
assert.equal(getCardValue("Q♦"), 10);
assert.equal(getCardValue("K♥"), 10);
})

test("Number cards 2 to 10 return their numbers", () => {
for(let n = 2; n <= 10; n++) {
assert.equal(getCardValue(`${n}♦`), n);
}
});

test("Only valid double-digit '10' card", () => {
assert.equal(getCardValue("10♥"), 10);
});

test("Accepts all four suits", () => {
for (const suit of ["♠", "♥", "♦", "♣"]){
assert.equal(getCardValue(`5${suit}`), 5);
}
});

test("Arbitrary non-card string", () => {
assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error");
});

// TODO: What other invalid card cases can you think of?
test("Missing suit", () => {
assert.throws(() => getCardValue("7"), /Expected a number followed by a suit/);
assert.throws(() => getCardValue("A"), /Expected a number followed by a suit/);
});

test("Missing ranks", () => {
assert.throws(() => getCardValue("♥"), /Expected a number followed by a suit/);
});

test("Empty strings", () => {
assert.throws(() => getCardValue(""), /Expected a number followed by a suit/);
});

test("Out-of-range number ranks", () => {
for (const OOR of ["0♥", "1♠", "11♦", "100♣"]) {
assert.throws(() => getCardValue(OOR), /Expected a number followed by a suit/);
}
});

test("Unknown suit", () => {
assert.throws(() => getCardValue("A❤"), /Expected a number followed by a suit/);
assert.throws(() => getCardValue("AV"), /Expected a number followed by a suit/);
});

test("Lowercase ranks", () => {
assert.throws(() => getCardValue("a♦"), /Expected a number followed by a suit/);
assert.throws(() => getCardValue("k♥"), /Expected a number followed by a suit/);
});

test("Suit before rank", () => {
assert.throws(() => getCardValue("♣A"), /Expected a number followed by a suit/);
});

test("Extra characters or spaces", () => {
for (const ExS of [" A♦", "A♦ ", "A♦♦", "A ♦"]){
assert.throws(() => getCardValue(ExS), /Expected a number followed by a suit/);
}
});

test("Non-string input", () => {
assert.throws(() => getCardValue(undefined), /Expected a number followed by a suit/);
assert.throws(() => getCardValue(5), /Expected a number followed by a suit/);
});
14 changes: 13 additions & 1 deletion implement-and-rewrite-tests/implement/1-get-angle-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,17 @@
// execute the code to ensure all tests pass.

export function getAngleType(angle) {
// TODO: Implement this function
if(angle > 0 && 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 {
return "Invalid angle";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@
// execute the code to ensure all tests pass.

export function isProperFraction(numerator, denominator) {
// TODO: Implement this function
if(Math.abs(numerator) < Math.abs(denominator)){
return true;
} else {
return false;
}
}
28 changes: 27 additions & 1 deletion implement-and-rewrite-tests/implement/3-get-card-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,31 @@
// execute the code to ensure all tests pass.

export function getCardValue(card) {
// TODO: Implement this function
const validSuits = ["♠", "♥", "♦", "♣"];
const numberRanks = ["2", "3", "4", "5", "6", "7", "8", "9", "10"];
const faceRanks = ["J", "Q", "K"];

const error = new Error(`Expected a number followed by a suit, but got "${card}"`);

if(typeof card !== "string" || card.length < 2){
throw error;
}

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

if(!validSuits.includes(suit)){
throw error;
}
if(rank === "A") {
return 11;
}
if(faceRanks.includes(rank)){
return 10;
}
if(numberRanks.includes(rank)){
return Number(rank);
}
throw error;
}