Skip to content

Commit 8f6c8dd

Browse files
Alex JamshidiAlex Jamshidi
authored andcommitted
formatted with prettier
1 parent a578ff8 commit 8f6c8dd

8 files changed

Lines changed: 34 additions & 32 deletions

File tree

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@
44
// str is already a declared variable fed into the capitalise function, the function attempts
55
// to declare the variable again, this may throw an error.
66

7-
87
// call the function capitalise with a string input
98
// interpret the error message and figure out why an error is occurring
109

11-
1210
// Error:
1311

1412
// let str = `${str[0].toUpperCase()}${str.slice(1)}`;
1513
// SyntaxError: Identifier 'str' has already been declared
1614

17-
1815
/* Original Code:
1916
2017
function capitalise(str) {
@@ -33,4 +30,3 @@ function capitalise(str) {
3330
str = `${str[0].toUpperCase()}${str.slice(1)}`;
3431
return str;
3532
}
36-

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ function convertToPercentage(decimalNumber) {
3333
return percentage;
3434
}
3535

36-
console.log(decimalNumber);
36+
console.log(decimalNumber);

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
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
@@ -24,7 +23,5 @@ function square(3) {
2423
// =============> write your new code here
2524

2625
function square(num) {
27-
return num * num;
26+
return num * num;
2827
}
29-
30-

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

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

33
// =============> write your prediction here
44
// The multiple function doesn't return anything
5-
// the console log that calls the multiple function will not receive anything back, this
5+
// the console log that calls the multiple function will not receive anything back, this
66
// may cause an error
77

88
/* Original code:
@@ -21,7 +21,7 @@ console.log(`The result of multiplying 10 and 32 is ${multiply(10, 32)}`);
2121

2222
// =============> write your new code here
2323
function multiply(a, b) {
24-
return (a * b);
24+
return a * b;
2525
}
2626

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

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

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

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

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 (weight / (height^2)).toFixed(1)
19-
}
18+
return (weight / (height ^ 2)).toFixed(1);
19+
}

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

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

1818
function upperSnakeCase(str) {
19-
const upperCaseStr = str.toUpperCase();
20-
return upperCaseStr.replaceAll(" ","_");
19+
const upperCaseStr = str.toUpperCase();
20+
return upperCaseStr.replaceAll(" ", "_");
2121
}
2222

2323
//tests
@@ -26,5 +26,6 @@ console.log(upperSnakeCase("hello world"));
2626
console.log(upperSnakeCase("h e l l o w o r l d "));
2727
console.log(upperSnakeCase(" hello world "));
2828
console.log(upperSnakeCase("hello 5555 world 6666 "));
29-
console.log(upperSnakeCase("hello world the quick brown fox jumps over the lazy dog"));
30-
29+
console.log(
30+
upperSnakeCase("hello world the quick brown fox jumps over the lazy dog")
31+
);

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

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,27 @@
88
const penceString = "399p";
99

1010
function toPounds(penceString) {
11-
const penceStringWithoutTrailingP = penceString.substring(0, penceString.length - 1);
12-
const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
13-
const pounds = paddedPenceNumberString.substring(0, paddedPenceNumberString.length - 2);
14-
const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0");
15-
return ${pounds}.${pence}`
11+
const penceStringWithoutTrailingP = penceString.substring(
12+
0,
13+
penceString.length - 1
14+
);
15+
const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
16+
const pounds = paddedPenceNumberString.substring(
17+
0,
18+
paddedPenceNumberString.length - 2
19+
);
20+
const pence = paddedPenceNumberString
21+
.substring(paddedPenceNumberString.length - 2)
22+
.padEnd(2, "0");
23+
return ${pounds}.${pence}`;
1624
}
1725

1826
//Tests
19-
console.log(toPounds("399p"))
20-
console.log(toPounds("3599p"))
21-
console.log(toPounds("390p"))
22-
console.log(toPounds("9p"))
23-
console.log(toPounds("666399p"))
24-
console.log(toPounds("30000001p"))
25-
console.log(toPounds("99p"))
26-
console.log(toPounds("300p"))
27+
console.log(toPounds("399p"));
28+
console.log(toPounds("3599p"));
29+
console.log(toPounds("390p"));
30+
console.log(toPounds("9p"));
31+
console.log(toPounds("666399p"));
32+
console.log(toPounds("30000001p"));
33+
console.log(toPounds("99p"));
34+
console.log(toPounds("300p"));

0 commit comments

Comments
 (0)