Skip to content

Commit c6fe4be

Browse files
Sprint 3 implement and rewrite tests
1 parent 49fe3af commit c6fe4be

File tree

20 files changed

+214
-75
lines changed

20 files changed

+214
-75
lines changed

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore artifacts:
2+
build
3+
coverage

.prettierrc

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1 @@
1-
{
2-
"arrowParens": "always",
3-
"bracketSpacing": true,
4-
"embeddedLanguageFormatting": "auto",
5-
"htmlWhitespaceSensitivity": "css",
6-
"insertPragma": false,
7-
"jsxBracketSameLine": false,
8-
"jsxSingleQuote": false,
9-
"printWidth": 80,
10-
"proseWrap": "preserve",
11-
"quoteProps": "as-needed",
12-
"requirePragma": false,
13-
"semi": true,
14-
"singleQuote": false,
15-
"tabWidth": 2,
16-
"trailingComma": "es5",
17-
"useTabs": false,
18-
"vueIndentScriptAndStyle": false
19-
}
1+
{}

Sprint-1/1-key-exercises/2-initials.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ let lastName = "Johnson";
88
let initials = ``;
99

1010
// https://www.google.com/search?q=get+first+character+of+string+mdn
11-

Sprint-1/3-mandatory-interpret/3-to-pounds.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ const penceString = "399p";
22

33
const penceStringWithoutTrailingP = penceString.substring(
44
0,
5-
penceString.length - 1
5+
penceString.length - 1,
66
);
77

88
const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
99
const pounds = paddedPenceNumberString.substring(
1010
0,
11-
paddedPenceNumberString.length - 2
11+
paddedPenceNumberString.length - 2,
1212
);
1313

1414
const pence = paddedPenceNumberString

Sprint-1/readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This README will guide you through the different sections for this week.
1212

1313
## 1 Exercises
1414

15-
In this section, you'll have a short program and task. Some of the syntax may be unfamiliar - in this case, you'll need to look things up in documentation.
15+
In this section, you'll have a short program and task. Some of the syntax may be unfamiliar - in this case, you'll need to look things up in documentation.
1616

1717
https://developer.mozilla.org/en-US/docs/Web/JavaScript
1818

@@ -28,7 +28,7 @@ You must use documentation to make sense of anything unfamiliar - learning how t
2828

2929
You can also use `console.log` to check the value of different variables in the code.
3030

31-
https://developer.mozilla.org/en-US/docs/Web/JavaScript
31+
https://developer.mozilla.org/en-US/docs/Web/JavaScript
3232

3333
## 4 Explore - Stretch 💪
3434

Sprint-2/3-mandatory-implement/1-bmi.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
// It should return their Body Mass Index to 1 decimal place
1616

1717
function calculateBMI(weight, height) {
18-
// return the BMI of someone based off their weight and height
19-
}
18+
// return the BMI of someone based off their weight and height
19+
}

Sprint-2/5-stretch-extend/format-time.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ const currentOutput = formatAs12HourClock("08:00");
1414
const targetOutput = "08:00 am";
1515
console.assert(
1616
currentOutput === targetOutput,
17-
`current output: ${currentOutput}, target output: ${targetOutput}`
17+
`current output: ${currentOutput}, target output: ${targetOutput}`,
1818
);
1919

2020
const currentOutput2 = formatAs12HourClock("23:00");
2121
const targetOutput2 = "11:00 pm";
2222
console.assert(
2323
currentOutput2 === targetOutput2,
24-
`current output: ${currentOutput2}, target output: ${targetOutput2}`
24+
`current output: ${currentOutput2}, target output: ${targetOutput2}`,
2525
);

Sprint-3/1-implement-and-rewrite-tests/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ to choose test values that thoroughly test a function.
55

66
## 1 Implement solutions
77

8-
In the `implement` directory you've got a number of functions you'll need to implement.
9-
For each function, you also have a number of different cases you'll need to check for your function.
8+
Here is a recommended order:
109

11-
Write your assertions and build up your program case by case. Don't rush to a solution. The point of these assignments is to learn how to write assertions and build up a program step by step.
10+
1. `1-get-angle-type.js`In the `implement` directory you've got a number of functions you'll need to implement.
11+
For each function, you also have a number of different cases you'll need to check for your function.
1212

13-
Here is a recommended order:
13+
Write your assertions and build up your program case by case. Don't rush to a solution. The point of these assignments is to learn how to write assertions and build up a program step by step.
1414

15-
1. `1-get-angle-type.js`
1615
2. `2-is-proper-fraction.js`
1716
3. `3-get-card-value.js`
1817

Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,19 @@
1515
// execute the code to ensure all tests pass.
1616

1717
function getAngleType(angle) {
18-
// TODO: Implement this function
18+
if (angle > 0 && angle < 90) {
19+
return "Acute angle";
20+
} else if (angle === 90) {
21+
return "Right angle";
22+
} else if (angle > 90 && angle < 180) {
23+
return "Obtuse angle";
24+
} else if (angle === 180) {
25+
return "Straight angle";
26+
} else if (angle > 180 && angle < 360) {
27+
return "Reflex angle";
28+
} else {
29+
return "Invalid angle";
30+
}
1931
}
2032

2133
// The line below allows us to load the getAngleType function into tests in other files.
@@ -27,11 +39,29 @@ module.exports = getAngleType;
2739
function assertEquals(actualOutput, targetOutput) {
2840
console.assert(
2941
actualOutput === targetOutput,
30-
`Expected ${actualOutput} to equal ${targetOutput}`
42+
`Expected ${actualOutput} to equal ${targetOutput}`,
3143
);
3244
}
3345

3446
// TODO: Write tests to cover all cases, including boundary and invalid cases.
3547
// Example: Identify Right Angles
36-
const right = getAngleType(90);
48+
let invalid = getAngleType(0);
49+
assertEquals(invalid, "Invalid angle");
50+
let acute = getAngleType(1);
51+
assertEquals(acute, "Acute angle");
52+
acute = getAngleType(89);
53+
assertEquals(acute, "Acute angle");
54+
let right = getAngleType(90);
3755
assertEquals(right, "Right angle");
56+
let obtuse = getAngleType(91);
57+
assertEquals(obtuse, "Obtuse angle");
58+
obtuse = getAngleType(179);
59+
assertEquals(obtuse, "Obtuse angle");
60+
const straight = getAngleType(180);
61+
assertEquals(straight, "Straight angle");
62+
let reflex = getAngleType(181);
63+
assertEquals(reflex, "Reflex angle");
64+
reflex = getAngleType(359);
65+
assertEquals(reflex, "Reflex angle");
66+
invalid = getAngleType(400);
67+
assertEquals(invalid, "Invalid angle");

Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
// execute the code to ensure all tests pass.
1212

1313
function isProperFraction(numerator, denominator) {
14-
// TODO: Implement this function
14+
if (denominator === 0) {
15+
return false;
16+
}
17+
return Math.abs(numerator) < Math.abs(denominator);
18+
1519
}
1620

1721
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -22,7 +26,7 @@ module.exports = isProperFraction;
2226
function assertEquals(actualOutput, targetOutput) {
2327
console.assert(
2428
actualOutput === targetOutput,
25-
`Expected ${actualOutput} to equal ${targetOutput}`
29+
`Expected ${actualOutput} to equal ${targetOutput}`,
2630
);
2731
}
2832

@@ -31,3 +35,10 @@ function assertEquals(actualOutput, targetOutput) {
3135

3236
// Example: 1/2 is a proper fraction
3337
assertEquals(isProperFraction(1, 2), true);
38+
assertEquals(isProperFraction(5, 4), false);
39+
assertEquals(isProperFraction(3, 3), false);
40+
assertEquals(isProperFraction(0, 5), true);
41+
assertEquals(isProperFraction(1, 0), false);
42+
assertEquals(isProperFraction(-1, 2), true);
43+
assertEquals(isProperFraction(1, -2), true);
44+
assertEquals(isProperFraction(-1, -2), true);

0 commit comments

Comments
 (0)