Skip to content

Commit 49aa90d

Browse files
committed
Formatted all files with prettier
1 parent 50f9d8c commit 49aa90d

8 files changed

Lines changed: 12 additions & 40 deletions

File tree

‎Sprint-2/1-key-exercises/3-paths.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ console.log(`The base part of ${filePath} is ${base}`);
1717
// Create a variable to store the dir part of the filePath variable
1818
// Create a variable to store the ext part of the variable
1919

20-
const dir = filePath.slice(0,lastSlashIndex);
20+
const dir = filePath.slice(0, lastSlashIndex);
2121
console.log(`The dir parth of ${filePath} is ${dir}`);
2222

2323
const lastPeriodIndex = filePath.lastIndexOf(".");
2424
const ext = filePath.slice(lastPeriodIndex);
2525
console.log(`The ext part of ${filePath} is ${ext}`);
2626

27-
// https://www.google.com/search?q=slice+mdn
27+
// https://www.google.com/search?q=slice+mdn

‎Sprint-2/1-key-exercises/4-random.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ console.log(num);
1212

1313
// Answer: num is a random number between 1 and 100, including 1 and 100. So if I change the values of minimum
1414
// and maximum it will be a random value between them, including them.
15-
15+
1616
// Math.random generates a random value between 0 and 1, including 0 but not 1.
1717

1818
// (maximum - minimum + 1) gives the amounts of values we want to be able to generate.

‎Sprint-2/2-mandatory-errors/0.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// This is just an instruction for the first activity - but it is just for human consumption
22
// We don't want the computer to run these 2 lines - how can we solve this problem?
33

4-
// Answer: I turned the lines into comments, now they won't run
4+
// Answer: I turned the lines into comments, now they won't run

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ console.log(last4Digits);
99
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
1010
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
1111

12-
13-
1412
// Prediction: I believe slice counts forward from the start when you use positive values, and
1513
// backwards from the end when you use negative. So if you only put in one negative number, it's counts
1614
// backward from the end to the last 4, but can't "turn around" to count up to the end again..?
@@ -22,4 +20,4 @@ console.log(last4Digits);
2220

2321
// I solved it by chaining a toString before slicing. My initial theory was completely wrong, putting a
2422
// negative number in slice is completely fine. Now last4Digits is a string, not a number. But it seems
25-
// easier to work with as a string, if specific digits need to be accessed, so I will keep it as a string.
23+
// easier to work with as a string, if specific digits need to be accessed, so I will keep it as a string.

‎Sprint-2/2-mandatory-errors/4.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ const twentyfourHourClockTime = "20:53";
33

44
// Answer: I got the error message SyntaxError: Invalid or unexpected token
55
// There were arrows pointing at "12" in 12HourClockTime. That is because
6-
// variable names cannot start with numbers in javascript. I changed them to start with letters.
6+
// variable names cannot start with numbers in javascript. I changed them to start with letters.

‎Sprint-2/3-mandatory-interpret/1-percentage-change.js‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,30 @@ console.log(`The percentage change is ${percentageChange}`);
1111

1212
// Read the code and then answer the questions below
1313

14-
15-
1614
// a) How many function calls are there in this file? Write down all the lines where a function call is made
1715

1816
// 5 function calls are made.
1917
// Line 4 calls function replaceAll and Number
2018
// Line 5 calls functions replaceAll and Number
2119
// Line 10 calls log
2220

23-
24-
2521
// b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem?
2622

2723
// There is a syntax error. The error says a closing parenthesis is missing, which I think is triggered
2824
// because a comma in the argument list is missing. I added the comma and the error is resolved.
2925

30-
31-
3226
// c) Identify all the lines that are variable reassignment statements
3327

3428
// Line 4 reassigning carPrice
3529
// Line 5 reassigning priceAfterOneYear
3630

37-
38-
3931
// d) Identify all the lines that are variable declarations
4032

4133
// Line 1 declares carPrice with let
4234
// Line 2 declares priceAfterOneYear with let
4335
// Line 7 declares priceDifference with const
4436
// Line 8 declares percentageChange with const
4537

46-
47-
4838
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
4939

5040
// The original carPrice is a string. In order to do math and get a percentage the string needs to be converted

‎Sprint-2/3-mandatory-interpret/2-time-format.js‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,28 @@ console.log(result);
1515

1616
// 6
1717

18-
19-
2018
// b) How many function calls are there?
2119

2220
// 1, console.log(result) on line 10
2321

24-
25-
2622
// c) Using documentation, explain what the expression movieLength % 60 represents
2723
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
2824

2925
// % is the remainder arithmetic operator. The expression gives the remainder after the number of seconds
3026
// the movie is long is divided by 60. After you have the full amount of minutes this is the amount of
3127
// remaining seconds that don't add up to a full minute.
3228

33-
34-
3529
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
3630

3731
// removing remainingSeconds from movieLength leaves a number of seconds, slightly shorter than the movie length,
38-
// that are an exact amount of minutes. It is divisible by 60. Dividing that number by 60 gives the exact
32+
// that are an exact amount of minutes. It is divisible by 60. Dividing that number by 60 gives the exact
3933
// number of minutes.
4034

41-
42-
4335
// e) What do you think the variable result represents? Can you think of a better name for this variable?
4436

4537
// It represents the movie length as a string expressed in hours, minutes and seconds. A different name could
4638
// be moiveLengthDestructured, movieLengthMessage, movieLengthInHMS, movieLengthFormatted, movieLengthTimeFormat
4739

48-
49-
5040
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
5141

5242
// It technically works for all movie lengths, but the format gets weird. when a value is a single digit, you

‎Sprint-2/3-mandatory-interpret/3-to-pounds.js‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ const penceString = "399p";
22

33
const penceStringWithoutTrailingP = penceString.substring(
44
0,
5-
penceString.length - 1
5+
penceString.length - 1,
66
);
77

88
const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
99

1010
const pounds = paddedPenceNumberString.substring(
1111
0,
12-
paddedPenceNumberString.length - 2
12+
paddedPenceNumberString.length - 2,
1313
);
1414

1515
const pence = paddedPenceNumberString
@@ -27,25 +27,21 @@ console.log(`£${pounds}.${pence}`);
2727
// To begin, we can start with
2828
// 1. const penceString = "399p": initialises a string variable with the value "399p"
2929

30-
3130
// Answers
3231

33-
3432
// 2. const penceStringWithoutTrailingP = penceString.substring(
35-
// 0,
36-
// penceString.length - 1
33+
// 0,
34+
// penceString.length - 1
3735
// );
3836
// This declares and initialises a new variable penceStringWithoutTrailingP that is a substring of
3937
// penceString, starting at position 0 and up to but not including the last position. So the new variable
4038
// gets the value "399", the p is left behind.
4139

42-
4340
// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0");
4441
// We now want our value to be at least 3 digits long, but in case it is shorter, we want to fill up with zeros at
4542
// the start so it becomes 3 digits long. padStart does that, the 3 specifies minimum amount of digits and the "0"
4643
// specifies what to fill with. The result gets saved in new variable paddedPenceNumberString.
4744

48-
4945
// 4. const pounds = paddedPenceNumberString.substring(
5046
// 0,
5147
// paddedPenceNumberString.length - 2
@@ -54,7 +50,6 @@ console.log(`£${pounds}.${pence}`);
5450
// by creating a substring from paddedPenceNumberString starting at position 0 and ending before the next to
5551
// last digit. The last two digits are the pence amount and they aren't included in pounds.
5652

57-
5853
// 5. const pence = paddedPenceNumberString
5954
// .substring(paddedPenceNumberString.length - 2)
6055
// .padEnd(2, "0");
@@ -66,7 +61,6 @@ console.log(`£${pounds}.${pence}`);
6661
// always already be 2 digits long. Even if penceString started with just 1 digit, "0"s will have been padded
6762
// earlier at the beginning of the string, so pence can always be 2 digits and the padEnd will never take effect.
6863

69-
7064
// 6. console.log(`£${pounds}.${pence}`);
7165
// Using a template literal, here we log the £ sign followed by the the pounds amount, a period and the pence
72-
// amount, which is formatted to understand easier than the original penceString was.
66+
// amount, which is formatted to understand easier than the original penceString was.

0 commit comments

Comments
 (0)