Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,57 @@ test("Classifies right angles", () => {
const right = getAngleType(90);
assert.equal(right, "Right angle");
});

test("Classifies Acute angles", () => {
const right = getAngleType(50);
assert.equal(right, "Acute angle");
});

test("Classifies Acute angles", () => {
const right = getAngleType(60.3);
assert.equal(right, "Acute angle");
});

test("Classifies Acute angles", () => {
const right = getAngleType(89.9);
assert.equal(right, "Acute angle");
});
test("Classifies Acute angles", () => {
const right = getAngleType(1);
assert.equal(right, "Acute angle");
});
test("Classifies Acute angles", () => {
const right = getAngleType(33.33);
assert.equal(right, "Acute angle");
});

test("Classifies Acute angles", () => {
const right = getAngleType(0.2);
assert.equal(right, "Acute angle");
});

test("Classifies Obtuse angles", () => {
const right = getAngleType(90.1);
assert.equal(right, "Obtuse angle");
});
test("Classifies Obtuse angles", () => {
const right = getAngleType(100.99);
assert.equal(right, "Obtuse angle");
});

test("Classifies Obtuse angles", () => {
const right = getAngleType(115);
assert.equal(right, "Obtuse angle");
});
test("Classifies Obtuse angles", () => {
const right = getAngleType(135);
assert.equal(right, "Obtuse angle");
});
test("Classifies Obtuse angles", () => {
const right = getAngleType(150);
assert.equal(right, "Obtuse angle");
});
test("Classifies Obtuse angles", () => {
const right = getAngleType(179);
assert.equal(right, "Obtuse angle");
});
21 changes: 0 additions & 21 deletions implement-and-rewrite-tests/implement/1-get-angle-type.js

This file was deleted.

9 changes: 8 additions & 1 deletion practice-tdd/count.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
export function countChar(stringOfCharacters, findCharacter) {
return 5
let count = 0;
for (let i = 0; i < stringOfCharacters.length; i++) {
if (stringOfCharacters[i] === findCharacter) {
count++;
}
}
return count;
}
console.log(countChar("bcdef", "a"));
6 changes: 6 additions & 0 deletions practice-tdd/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 `str`.
// When the function is called with these inputs,
// Then it should return 0, indicating that no occurrences of `char` were found.
test("should return 0 when there is not repeated char in str", () => {
const str = "hello";
const char = "a";
const count = countChar(str, char);
expect(count).toEqual(0);
});
17 changes: 16 additions & 1 deletion practice-tdd/get-ordinal-number.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
export function getOrdinalNumber(num) {
return "1st";
const lastTwoDigit = num % 100;
const lastDigit = num % 10;
if (lastTwoDigit >= 11 && lastTwoDigit <= 13) {
return `${num}th`;
}
if (lastDigit === 1) {
return `${num}st`;
}
if (lastDigit === 2) {
return `${num}nd`;
}
if (lastDigit === 3) {
return `${num}rd`;
}

return `${num}th`;
}
25 changes: 25 additions & 0 deletions practice-tdd/get-ordinal-number.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,28 @@ test("should append 'st' for numbers ending with 1, except those ending with 11"
expect(getOrdinalNumber(21)).toEqual("21st");
expect(getOrdinalNumber(131)).toEqual("131st");
});

test("should append 'nd' for numbers ending with 2, except those ending with 12", () => {
expect(getOrdinalNumber(2)).toEqual("2nd");
expect(getOrdinalNumber(22)).toEqual("22nd");
expect(getOrdinalNumber(132)).toEqual("132nd");
});

test("should append 'rd' for numbers ending with 3, except those ending with 13", () => {
expect(getOrdinalNumber(3)).toEqual("3rd");
expect(getOrdinalNumber(23)).toEqual("23rd");
expect(getOrdinalNumber(133)).toEqual("133rd");
});

test("should append 'th' for numbers ending with 11, 12 or 13", () => {
expect(getOrdinalNumber(11)).toEqual("11th");
expect(getOrdinalNumber(12)).toEqual("12th");
expect(getOrdinalNumber(13)).toEqual("13th");
expect(getOrdinalNumber(111)).toEqual("111th");
});

test("should append 'th' for all other numbers", () => {
expect(getOrdinalNumber(4)).toEqual("4th");
expect(getOrdinalNumber(10)).toEqual("10th");
expect(getOrdinalNumber(100)).toEqual("100th");
});
Loading