Skip to content

Commit db6a842

Browse files
committed
Fix: Remove unnecessary blank lines and ensure consistent formatting in multiple files
1 parent ae5326c commit db6a842

File tree

9 files changed

+39
-47
lines changed

9 files changed

+39
-47
lines changed

Sprint-2/1-key-errors/0.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ function capitalise(str) {
2121
return newStr;
2222
}
2323

24-
console.log(capitalise("hello world"));
24+
console.log(capitalise("hello world"));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
// =============> write your explanation here
1919
// SyntaxError: Identifier 'decimalNumber' has already been declared
20-
// This error occurs because we have declared the variable decimalNumber twice,
20+
// This error occurs because we have declared the variable decimalNumber twice,
2121
// once as a parameter and once as a variable inside the function.
2222

2323
// apparently there is another error that we only console logged the variable decimalNumber which is not declared in the global scope,

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
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 this is an obvious one because when defining a function you cant give a direct input like 3,
87
// instead you have to give a variable name as a parameter and then use that variable name in the function
9-
// body to perform the calculation. So I predict that there will be a syntax error because of the way
8+
// body to perform the calculation. So I predict that there will be a syntax error because of the way
109
// the function is defined with a direct input of 3 instead of a variable name.
1110

1211
// function square(3) {
1312
// return num * num;
1413
// }
1514

16-
17-
1815
// =============> write the error message here
1916
// /Users/me/CYF/Module-Structuring-and-Testing-Data/Sprint-2/1-key-errors/2.js:12
2017
// function square(3) {
@@ -30,9 +27,7 @@
3027
// =============> write your new code here
3128

3229
function square(num) {
33-
return num * num;
30+
return num * num;
3431
}
3532

3633
console.log(square(3));
37-
38-

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

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

33
// =============> write your prediction here
4-
// I predict that there will be error because the function will not return anything
4+
// I predict that there will be error because the function will not return anything
55
// and when we try to log the result of the function call to the console, it will return undefined.
66

77
// function multiply(a, b) {
@@ -11,7 +11,7 @@
1111
// console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
1212

1313
// =============> write your explanation here
14-
// The function multiply logs in the result of a * b to the console but does not return anything,
14+
// The function multiply logs in the result of a * b to the console but does not return anything,
1515
// so when we try to log the result of the function call to the console, it will return undefined.
1616

1717
// Finally, correct the code to fix the problem

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Predict and explain first...
22
// =============> write your prediction here
3-
// I predict there will be a syntax error but not sure what the error is yet.
3+
// I predict there will be a syntax error but not sure what the error is yet.
44
// I think it has something to do with return as it return nothing , so the function was'nt well defined.
55

66
// function sum(a, b) {
@@ -11,7 +11,7 @@
1111
// console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
1212

1313
// =============> write your explanation here
14-
// The function sum is not returning the result of a + b, instead it is returning undefined
14+
// The function sum is not returning the result of a + b, instead it is returning undefined
1515
// because the return statement is on a separate line and does not include the expression a + b.
1616

1717
// Finally, correct the code to fix the problem
@@ -22,4 +22,3 @@ function sum(a, b) {
2222
}
2323

2424
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
25-

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
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
18+
// return the BMI of someone based off their weight and height
1919

20-
const bmi = weight / (height * height);
21-
return Math.round(bmi * 10) / 10;
20+
const bmi = weight / (height * height);
21+
return Math.round(bmi * 10) / 10;
2222
}
2323

2424
// Example:
25-
console.log(calculateBMI(70, 1.73));
25+
console.log(calculateBMI(70, 1.73));

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

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

1818
function toUpperSnakeCase(str) {
19-
// return the string in UPPER_SNAKE_CASE
20-
21-
return str.replaceAll(" ", "_").toUpperCase();
22-
// I used replaceAll to replace all spaces with underscores and then used toUpperCase to convert the string to uppercase.
19+
// return the string in UPPER_SNAKE_CASE
20+
21+
return str.replaceAll(" ", "_").toUpperCase();
22+
// I used replaceAll to replace all spaces with underscores and then used toUpperCase to convert the string to uppercase.
2323
}
2424

25-
console.log(toUpperSnakeCase("hello there"));
25+
console.log(toUpperSnakeCase("hello there"));

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

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,36 @@
66
// You should call this function a number of times to check it works for different inputs
77

88
function toPounds(penceString) {
9-
// return the price in pounds
9+
// return the price in pounds
1010

11-
// I took the code and made it as a function called toPounds with a parameter called penceString,
12-
// but after reviewing the code in Ai I noticed i have to add something called defensive programming,
13-
// to make sure the input is following the format of a string with a number followed by the letter p,
14-
// so I will add an if statement to check if the input is valid and if not, using endWith() method and then return an error message.
11+
// I took the code and made it as a function called toPounds with a parameter called penceString,
12+
// but after reviewing the code in Ai I noticed i have to add something called defensive programming,
13+
// to make sure the input is following the format of a string with a number followed by the letter p,
14+
// so I will add an if statement to check if the input is valid and if not, using endWith() method and then return an error message.
1515

16-
17-
if (!penceString.endsWith("p")) {
16+
if (!penceString.endsWith("p")) {
1817
return "Error: Please enter a valid pence format (e.g., '399p')";
19-
}
18+
}
2019

21-
const penceStringWithoutTrailingP = penceString.substring(
22-
0,
23-
penceString.length - 1
24-
);
20+
const penceStringWithoutTrailingP = penceString.substring(
21+
0,
22+
penceString.length - 1
23+
);
2524

26-
const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
25+
const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
2726

28-
const pounds = paddedPenceNumberString.substring(
29-
0,
30-
paddedPenceNumberString.length - 2
31-
);
27+
const pounds = paddedPenceNumberString.substring(
28+
0,
29+
paddedPenceNumberString.length - 2
30+
);
3231

33-
const pence = paddedPenceNumberString
34-
.substring(paddedPenceNumberString.length - 2)
35-
.padEnd(2, "0");
32+
const pence = paddedPenceNumberString
33+
.substring(paddedPenceNumberString.length - 2)
34+
.padEnd(2, "0");
3635

37-
return (${pounds}.${pence}`);
36+
return ${pounds}.${pence}`;
3837
}
3938

4039
console.log(toPounds("399p"));
4140
console.log(toPounds("5p"));
4241
console.log(toPounds("abc"));
43-

Sprint-2/4-mandatory-interpret/time-format.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ console.log(formatTimeDisplay(61));
3030

3131
// c) What is the return value of pad is called for the first time?
3232
// =============> write your answer here
33-
// The return value of pad when it is called for the first time is "00"
33+
// The return value of pad when it is called for the first time is "00"
3434

3535
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
3636
// =============> write your answer here
@@ -40,4 +40,4 @@ console.log(formatTimeDisplay(61));
4040
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
4141
// =============> write your answer here
4242
// The return value assigned to num when pad is called for the last time in this program is "01".
43-
// This is because pad(1) returns "01" since 1 is padded to 2 digits with leading zeros.
43+
// This is because pad(1) returns "01" since 1 is padded to 2 digits with leading zeros.

0 commit comments

Comments
 (0)