Skip to content

Commit 39f9cac

Browse files
Revert accidental changes to sprint 2
1 parent c572b4d commit 39f9cac

File tree

11 files changed

+29
-90
lines changed

11 files changed

+29
-90
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Predict and explain first...
2-
// =============> Capitalises the first letter of the str
2+
// =============> write your prediction here
33

44
// call the function capitalise with a string input
55
// interpret the error message and figure out why an error is occurring
@@ -9,7 +9,5 @@ function capitalise(str) {
99
return str;
1010
}
1111

12-
capitalise("mohsen");
13-
14-
// =============> variable str is declared again inside function
15-
// =============> str = `${str[0].toUpperCase()}${str.slice(1)}`;
12+
// =============> write your explanation here
13+
// =============> write your new code here

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

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

33
// Why will an error occur when this program runs?
4-
// =============> Instead of calling the function, a variable is called
4+
// =============> write your prediction here
55

66
// Try playing computer with the example to work out what is going on
77

@@ -14,7 +14,7 @@ function convertToPercentage(decimalNumber) {
1414

1515
console.log(decimalNumber);
1616

17-
// =============> Also inside the function, decimalNumber is called again
17+
// =============> write your explanation here
1818

1919
// Finally, correct the code to fix the problem
20-
// =============> decimalNumber = 0.5;
20+
// =============> write your new code here

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

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

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

6-
// =============> The variable num is not declared
6+
// =============> write your prediction of the error here
77

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

12-
// =============>SyntaxError: Unexpected number
12+
// =============> write the error message here
1313

14-
// =============> There must a variable declared, not just simply passing a number as an argument
14+
// =============> explain this error message here
1515

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

18-
// =============> function square(num) {
18+
// =============> write your new code here
1919

2020

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

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

3-
// =============> the result of the multiply is printed inside function, and at the function call is will be undefined
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 function is not returning any value
11+
// =============> write your explanation here
1212

1313
// Finally, correct the code to fix the problem
14-
// =============> return a * b;
14+
// =============> write your new code here

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Predict and explain first...
2-
// =============> undefined will be printed
2+
// =============> write your prediction here
33

44
function sum(a, b) {
55
return;
@@ -8,6 +8,6 @@ function sum(a, b) {
88

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

11-
// =============> because the function returns nothing
11+
// =============> write your explanation here
1212
// Finally, correct the code to fix the problem
13-
// =============> return a + b;
13+
// =============> write your new code here

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

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

33
// Predict the output of the following code:
4-
// =============> the last digit of every function call will be 3
4+
// =============> Write your prediction here
55

66
const num = 103;
77

8-
function getLastDigit(num) {
8+
function getLastDigit() {
99
return num.toString().slice(-1);
1010
}
1111

@@ -16,10 +16,9 @@ console.log(`The last digit of 806 is ${getLastDigit(806)}`);
1616
// Now run the code and compare the output to your prediction
1717
// =============> write the output here
1818
// Explain why the output is the way it is
19-
// =============> function is using the num declared before it , not the number passed to it
19+
// =============> write your explanation here
2020
// Finally, correct the code to fix the problem
21-
// =============> function getLastDigit(num) {
21+
// =============> write your new code here
2222

2323
// This program should tell the user the last digit of each number.
2424
// Explain why getLastDigit is not working properly - correct the problem
25-
// Variable num used inside the function, should be passed as an argument

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +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-
const bmi = weight / height ** 2;
20-
return bmi.toFixed(1);
21-
}
22-
console.log(calculateBMI(70, 1.73));
18+
// return the BMI of someone based off their weight and height
19+
}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +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-
function makeUpperSnakeCase(str) {
18-
return str.toUpperCase().split(" ").join("_");
19-
}

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +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-
function toPounds(penceString) {
9-
const penceStringWithoutTrailingP = penceString.substring(
10-
0,
11-
penceString.length - 1
12-
);
13-
14-
const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
15-
const pounds = paddedPenceNumberString.substring(
16-
0,
17-
paddedPenceNumberString.length - 2
18-
);
19-
20-
const pence = paddedPenceNumberString
21-
.substring(paddedPenceNumberString.length - 2)
22-
.padEnd(2, "0");
23-
24-
return ${pounds}.${pence}`;
25-
}

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,18 @@ function formatTimeDisplay(seconds) {
1717
// Questions
1818

1919
// a) When formatTimeDisplay is called how many times will pad be called?
20-
// =============> 3
21-
formatTimeDisplay(61);
20+
// =============> write your answer here
2221

2322
// Call formatTimeDisplay with an input of 61, now answer the following:
2423

2524
// b) What is the value assigned to num when pad is called for the first time?
26-
// =============> 0
25+
// =============> write your answer here
2726

2827
// c) What is the return value of pad is called for the first time?
29-
// =============> It is called return value and will be '00'
28+
// =============> write your answer here
3029

3130
// d) What is the value assigned to num when pad is called for the last time in this program? Explain your answer
32-
// =============> The function is passed 61 which means 1 minute and 1 second so the value passed to pad for the last call is 1
31+
// =============> write your answer here
3332

3433
// e) What is the return value assigned to num when pad is called for the last time in this program? Explain your answer
35-
// =============> 1 is passed to function as a number and stored in num then num is turned into a string and one '0' will be added
36-
// to the beginning of num so the returned value will be '01'
34+
// =============> write your answer here

0 commit comments

Comments
 (0)