Skip to content

Commit cc958de

Browse files
author
JorvanW
committed
removed code from Sprint-2
1 parent a85a823 commit cc958de

11 files changed

Lines changed: 29 additions & 105 deletions

File tree

Sprint-1/1-key-exercises/1-count.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,4 @@ let count = 0;
33
count = count + 1;
44

55
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
6-
// Describe what line 3 is doing, in particular focus on what = is doing
7-
8-
// = is assigning the value of 'count',
9-
// 'let' is a declararation than enables its subject (count) to be changed
10-
// line 3 is taking the current value in line 1 (0) and by using '=' it is reassigning the value of 'count' to equal itself plus 1
6+
// Describe what line 3 is doing, in particular focus on what = is doing

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Predict and explain first...
2-
// =============> The fuction intends to capitalize the first letter of the input string
3-
// from th left starting with the first character (str[0]).
2+
// =============> write your prediction here
43

54
// call the function capitalise with a string input
65
// interpret the error message and figure out why an error is occurring
@@ -10,8 +9,5 @@ function capitalise(str) {
109
return str;
1110
}
1211

13-
// =============> str has already been declared as a parameter function, so it cannot be redeclared within the function body. This will cause a syntax error. To fix this, we should use a different variable name for the new string we are creating.
14-
// =============>
15-
function capitalise(str) {
16-
str = `${str[0].toUpperCase()}${str.slice(1)}`;
17-
return str;
12+
// =============> write your explanation here
13+
// =============> write your new code here

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

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

3-
// Why will an error occur when this program runs?
4-
// =============> decimalNumber is a constant variable, and cannot be changed.
5-
// The code is attempting to change it which will cause an error.
3+
// Why will an error occur when this program runs?
4+
// =============> write your prediction here
65

76
// Try playing computer with the example to work out what is going on
87

@@ -15,12 +14,7 @@ function convertToPercentage(decimalNumber) {
1514

1615
console.log(decimalNumber);
1716

18-
// =============> The code is attempting to get the percentage of decimalNumber
17+
// =============> write your explanation here
1918

2019
// Finally, correct the code to fix the problem
21-
function convertToPercentage(decimalNumber) {
22-
decimalNumber = 0.5;
23-
const percentage = `${decimalNumber * 100}%`;
24-
return percentage;
25-
}
26-
console.log (convertToPercentage(0.5));
20+
// =============> write your new code here

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,18 @@
33

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

6-
// =============> num is not defined which causes an error.
6+
// =============> write your prediction of the error here
77

88
function square(3) {
99
return num * num;
1010
}
1111

12-
// =============> 1. "Uncaught SyntaxError: Unexpected number" Means the "3" is not valid there.
13-
// 2. Uncaught SyntaxError: Illegal return statement. Means "num" has no idea of what it should be
12+
// =============> write the error message here
1413

14+
// =============> explain this error message here
1515

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

18-
// =============> by adding square(num) the function will work when given a number
19-
function square(num) {
20-
return num * num;
21-
}
22-
console.log(square(3))
18+
// =============> write your new code here
2319

2420

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

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

3-
// =============> Code is attempting to multiple a & b but there is no return value
3+
// =============> write your prediction here
44

55
function multiply(a, b) {
66
console.log(a * b);
77
}
88

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

11-
// =============> because there is no return value, the outcome stays as undefined while giving the answer
12-
// to fix this, change "console.log" in the second row to "return"
13-
//
11+
// =============> write your explanation here
1412

1513
// Finally, correct the code to fix the problem
16-
function multiply(a, b) {
17-
return (a * b);
18-
}
14+
// =============> write your new code here

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Predict and explain first...
2-
// =============> the function is attempting to add "a" & "b" together
3-
// but the return is formatted wrong.
2+
// =============> write your prediction here
43

54
function sum(a, b) {
65
return;
@@ -9,12 +8,6 @@ function sum(a, b) {
98

109
console.log(`The sum of 10 and 32 is ${sum(10, 32)}`);
1110

12-
// =============> because of the way line 6 and 7 is written the answer will be undefined.
13-
//remove the semi colon from line 6 and then add line 7 to it.
11+
// =============> write your explanation here
1412
// Finally, correct the code to fix the problem
15-
16-
function sum(a, b) {
17-
return (a + b);
18-
}
19-
20-
console.log(sum(10, 32))
13+
// =============> write your new code here

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

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

33
// Predict the output of the following code:
4-
// =============> The function is trying to get the last digit of "num"
5-
// but because on "const", the "num" is always locked to "103" leaving the return always "3"
4+
// =============> Write your prediction here
65

76
const num = 103;
87

@@ -15,22 +14,11 @@ console.log(`The last digit of 105 is ${getLastDigit(105)}`);
1514
console.log(`The last digit of 806 is ${getLastDigit(806)}`);
1615

1716
// Now run the code and compare the output to your prediction
18-
// =============> Just as predicted, the function is trying to get the last digit, which is always "3"
17+
// =============> write the output here
1918
// Explain why the output is the way it is
20-
// =============> because of "const" the num is always locked to "103"
19+
// =============> write your explanation here
2120
// Finally, correct the code to fix the problem
22-
23-
function getLastDigit(num) {
24-
return num.toString().slice(-1);
25-
}
26-
27-
console.log(`The last digit of 42 is ${getLastDigit(42)}`);
28-
console.log(`The last digit of 105 is ${getLastDigit(105)}`);
29-
console.log(`The last digit of 806 is ${getLastDigit(806)}`);
30-
21+
// =============> write your new code here
3122

3223
// This program should tell the user the last digit of each number.
33-
// Explain why getLastDigit is not working properly
34-
// It's not working properly because of the "const num = 103"
35-
// to fix, I have removed the line and added "(num)" after "function getLastDigit"
36-
// In order to define what "num" is.
24+
// Explain why getLastDigit is not working properly - correct the problem

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,4 @@
1616

1717
function calculateBMI(weight, height) {
1818
// return the BMI of someone based off their weight and height
19-
}
20-
21-
function calculateBMI(weight, height) {
22-
const bmi = weight / (height * height);
23-
return parseFloat(bmi.toFixed(1));
24-
}
25-
26-
console.log(calculateBMI(70, 1.73));
19+
}

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,3 @@
1414
// You will need to come up with an appropriate name for the function
1515
// Use the MDN string documentation to help you find a solution
1616
// This might help https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase
17-
18-
19-
function Capitalise(inputString) {
20-
return inputString.toUpperCase()
21-
22-
}
23-
24-
Console.log(Capitalise("hello there"));

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

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,3 @@
44
// You will need to declare a function called toPounds with an appropriately named parameter.
55

66
// You should call this function a number of times to check it works for different inputs
7-
8-
const penceString = "399p";
9-
10-
const penceStringWithoutTrailingP = penceString.substring(
11-
0,
12-
penceString.length - 1
13-
);
14-
15-
const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
16-
const pounds = paddedPenceNumberString.substring(
17-
0,
18-
paddedPenceNumberString.length - 2
19-
);
20-
21-
const pence = paddedPenceNumberString
22-
.substring(paddedPenceNumberString.length - 2)
23-
.padEnd(2, "0");
24-
25-
console.log(${pounds}.${pence}`);
26-

0 commit comments

Comments
 (0)