Skip to content

Commit 107eaf2

Browse files
Format Sprint 3 with Prettier
1 parent 7d4385b commit 107eaf2

10 files changed

Lines changed: 32 additions & 52 deletions

File tree

‎Sprint-3/1-key-errors/0.js‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
*/
1212

1313
// The error happens because str is declared twice, once as a parameter & again with let
14-
// If I give the new variable a different name, I hope it should work :)
15-
14+
// If I give the new variable a different name, I hope it should work :)
1615

1716
function capitalise(str) {
1817
let newString = `${str[0].toUpperCase()}${str.slice(1)}`;
1918
return newString;
2019
}
2120

22-
console.log(capitalise("frumentius"));
21+
console.log(capitalise("frumentius"));

‎Sprint-3/1-key-errors/1.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ function convertToPercentage(decimalNumber) {
2929
return percentage;
3030
}
3131

32-
console.log(convertToPercentage("26"));
32+
console.log(convertToPercentage("26"));

‎Sprint-3/1-key-errors/2.js‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
1-
21
// Predict and explain first BEFORE you run any code...
32

43
// this function should square any number but instead we're going to get an error
54

65
// =============> write your prediction of the error here
76
// I think using 3 will cause an error as parameter
8-
// A parameter must be a valid variable name, not a number
7+
// A parameter must be a valid variable name, not a number
98

10-
/* function square(3){
9+
/* function square(3){
1110
return num * num;
1211
1312
}
1413
*/
15-
16-
// =============> write the error message here
14+
15+
// =============> write the error message here
1716
// SyntaxError: Unexpected number
1817

1918
// =============> explain this error message here
2019
// The parser sees the number 3 where it expects a valid parameter name,
2120
// so it cannot understand the structure of the function
2221
// It means we cannot use a number as a parameter name
2322

24-
2523
// Finally, correct the code to fix the problem
2624

2725
// =============> write your new code here
2826

29-
function square(num){
30-
return num * num;
31-
27+
function square(num) {
28+
return num * num;
3229
}
33-
console.log(square(7));
30+
console.log(square(7));

‎Sprint-3/2-mandatory-debug/0.js‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
// Predict and explain first...
22

33
// =============> write your prediction here
4-
// I believe the function will calculate 10 x 32
4+
// I believe the function will calculate 10 x 32
55

66
function multiply(a, b) {
77
console.log(a * b);
8-
98
}
109

1110
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1211

1312
// =============> write your explanation here
1413

15-
// After calling multiply(10, 32), the result is undefined because there is no return statement
14+
// After calling multiply(10, 32), the result is undefined because there is no return statement
1615
// It can still print 320 because console.log() prints the result inside the function
1716

1817
// Finally, correct the code to fix the problem
@@ -22,4 +21,4 @@ function multiply(a, b) {
2221
console.log(a * b);
2322
return a * b;
2423
}
25-
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
24+
console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);

‎Sprint-3/2-mandatory-debug/1.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Predict and explain first...
22
// =============> write your prediction here
3-
// I guess the function will return error or undefined because the return;
3+
// I guess the function will return error or undefined because the return;
44

55
/*function sum(a, b) {
66
return;

‎Sprint-3/2-mandatory-debug/2.js‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Predict the output of the following code:
44
// =============> Write your prediction here
5-
// The output will be the same because we don't give the function a parameter
5+
// The output will be the same because we don't give the function a parameter
66

77
/*const num = 103;
88
@@ -22,7 +22,6 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`); */
2222
// =============> write your explanation here
2323
// Because of the global variable and also because the function has no parameter
2424

25-
2625
// Finally, correct the code to fix the problem
2726
// =============> write your new code here
2827

@@ -36,8 +35,7 @@ console.log(`The last digit of 42 is ${getLastDigit(42)}`);
3635
console.log(`The last digit of 105 is ${getLastDigit(105)}`);
3736
console.log(`The last digit of 806 is ${getLastDigit(806)}`);
3837

39-
4038
// This program should tell the user the last digit of each number.
4139
// Explain why getLastDigit is not working properly - correct the problem
4240

43-
// Because the function was using the global variable, it ignored the arguments passed to it outside of the function box
41+
// Because the function was using the global variable, it ignored the arguments passed to it outside of the function box

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

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

1717
function calculateBMI(weight, height) {
18-
let BMI = weight / (height * height)
19-
20-
return BMI.toFixed(1);
18+
let BMI = weight / (height * height);
2119

22-
20+
return BMI.toFixed(1);
2321
}
2422
console.log(calculateBMI(62, 1.67));
2523

26-
// return the BMI of someone based off their weight and height
24+
// return the BMI of someone based off their weight and height

‎Sprint-3/3-mandatory-implement/2-cases.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
1717

1818
function toUpper(input) {
19-
return input.replaceAll(" ", "_").toUpperCase();
20-
19+
return input.replaceAll(" ", "_").toUpperCase();
2120
}
2221

2322
console.log(toUpper("alpha and omega"));

‎Sprint-3/3-mandatory-implement/3-to-pounds.js‎

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,20 @@
55

66
// You should call this function a number of times to check it works for different inputs
77

8-
9-
10-
11-
128
function toPounds(amount) {
13-
const amountWithoutTrailingP = amount.substring(
14-
0,
15-
amount.length - 1
16-
);
9+
const amountWithoutTrailingP = amount.substring(0, amount.length - 1);
1710

18-
const paddedPenceNumberString = amountWithoutTrailingP.padStart(3, "0");
19-
const pounds = paddedPenceNumberString.substring(
20-
0,
21-
paddedPenceNumberString.length - 2
22-
);
11+
const paddedPenceNumberString = amountWithoutTrailingP.padStart(3, "0");
12+
const pounds = paddedPenceNumberString.substring(
13+
0,
14+
paddedPenceNumberString.length - 2,
15+
);
2316

24-
const pence = paddedPenceNumberString
25-
.substring(paddedPenceNumberString.length - 2)
26-
.padEnd(2, "0");
17+
const pence = paddedPenceNumberString
18+
.substring(paddedPenceNumberString.length - 2)
19+
.padEnd(2, "0");
2720

28-
return (`£${pounds}.${pence}`)
21+
return `£${pounds}.${pence}`;
2922
}
3023

31-
3224
console.log(toPounds("1250p"));
33-
34-

‎Sprint-3/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
);

0 commit comments

Comments
 (0)