Skip to content

Commit 299436c

Browse files
Alex JamshidiAlex Jamshidi
authored andcommitted
formatted with prettier
1 parent 51c7a88 commit 299436c

11 files changed

Lines changed: 25 additions & 31 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ count = count + 1;
66
// Describe what line 3 is doing, in particular focus on what = is doing
77

88
// Line 3 is reassigning the variable 'count' to a new value. The new value that 'count' will take on is the existing value plus 1.
9-
// Given count is assigned a value of 0 in line 1, after running line 3 the value of count would be expected to be 1.
9+
// Given count is assigned a value of 0 in line 1, after running line 3 the value of count would be expected to be 1.

Sprint-1/1-key-exercises/2-initials.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ let lastName = "Johnson";
55
// Declare a variable called initials that stores the first character of each string.
66
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution.
77

8-
let initials = firstName.charAt(0)
9-
+ middleName.charAt(0)
10-
+ lastName.charAt(0);
8+
let initials = firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0);
119

12-
// https://www.google.com/search?q=get+first+character+of+string+mdn
10+
// https://www.google.com/search?q=get+first+character+of+string+mdn

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,4 @@ const ext = filePath.slice(lastDotIndex);
2727
console.log(`The directory part of ${filePath} is ${dir}`);
2828
console.log(`The extension part of ${filePath} is ${ext}`);
2929

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

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
88
// It will help to think about the order in which expressions are evaluated
99
// Try logging the value of num and running the program several times to build an idea of what the program is doing
1010

11-
12-
console.log(num)
11+
console.log(num);
1312

1413
// num returns a value of 60, running it again returns a value of 15, looking at the code I see a .random() function
1514
// I can make a hypothesis that this returns a random number of some kind, hence the inconsistent result
@@ -18,25 +17,25 @@ console.log(num)
1817
// Code in inner-most brackets is evaluated first
1918
// I would expect (maximum - minimum + 1) to be evaluated first (100 - 1 + 1) would equal 100
2019

21-
console.log(maximum - minimum + 1)
20+
console.log(maximum - minimum + 1);
2221

2322
// the result was 100
2423
// this part of the code is then multiplied by Math.random()
2524

26-
console.log(Math.random())
25+
console.log(Math.random());
2726

2827
// running this code many times, it appears Math.random() returns a random number between 0 and 1
2928
// checking documentation online, this is correct (actually between 0 and 0.99999999999)
3029
// therefore Math.random() * (maximum - minimum + 1) should return a random number between 1 and 100
3130

32-
console.log(Math.random() * (maximum - minimum + 1))
31+
console.log(Math.random() * (maximum - minimum + 1));
3332

3433
// It does, it returns it with many decimal places, the result of num didn't have any decimal places
3534
// The next part of the code that is run is Math.floor, let's see what this does
3635

37-
const number = Math.random() * (maximum - minimum + 1)
38-
console.log(number)
39-
console.log(Math.floor(number))
36+
const number = Math.random() * (maximum - minimum + 1);
37+
console.log(number);
38+
console.log(Math.floor(number));
4039

4140
// because Math.random() creates a new random number every time it is run, I had to set the
4241
// result to a variable so I can use the same number in multiple functions
@@ -48,4 +47,4 @@ console.log(Math.floor(number))
4847
// The final part is the addition of minimum (+1)
4948

5049
// Therefore I can see this code produces a random whole integer between minimum and maximum
51-
// Which in this case is an integer between 1 and 100
50+
// Which in this case is an integer between 1 and 100

Sprint-1/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-
// I commented out the code so it is not run by the computer using '//'
4+
// I commented out the code so it is not run by the computer using '//'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ age = age + 1;
66
// The error is TypeError: Assignment to constant variable.
77
// This is occurring as a constant variable cannot be reassigned
88
// line 4 is trying to reassign the constant variable age
9-
// This could be navigated by using let instead of const, or assigning a new variable name for age + 1
9+
// This could be navigated by using let instead of const, or assigning a new variable name for age + 1

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ const cityOfBirth = "Bolton";
77
// error message: ReferenceError: Cannot access 'cityOfBirth' before initialization
88
// this is occurring as the computer runs the code from top to bottom
99
// the variable cityOfBirth is assigned in line 5 but is trying to be run in line 4
10-
// this could be fixed by swapping the lines around
10+
// this could be fixed by swapping the lines around

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const cardNumber = 4533787178994213;
22
const last4Digits = String(cardNumber).slice(-4);
33

4-
console.log(last4Digits)
4+
console.log(last4Digits);
55

66
// The last4Digits variable should store the last 4 digits of cardNumber
77
// However, the code isn't working

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ console.log(`The percentage change is ${percentageChange}`);
1717

1818
// 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?
1919

20-
2120
// Error: SyntaxError: missing ) after argument list (Line 5)
2221
// The arguments in the replaceAll function need to be comma separated, the difference can be seen from line 4 where the code
2322
// did not hit an error, adding in that comma will solve the error
@@ -32,14 +31,14 @@ console.log(`The percentage change is ${percentageChange}`);
3231

3332
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
3433

35-
// It looks like the function is removing the commas (by replacing them with nothing) from the string
34+
// It looks like the function is removing the commas (by replacing them with nothing) from the string
3635
// so there are only numbers left and then converting it into a Number data type
3736

38-
console.log(carPrice)
37+
console.log(carPrice);
3938

4039
// I commented out the line of code with an error and ran the code to confirm, it returned 10000
4140
// I can check it is a number by running a math operation on it
4241

43-
console.log(carPrice*2)
42+
console.log(carPrice * 2);
4443

45-
// result as expected
44+
// result as expected

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ console.log(result);
2424

2525
// % is a modulus operator
2626
// It acts as a divisor, but instead of returning the resultant division, it returns the remainder
27-
// So movieLength % 60 divides the movieLength into whole minutes and returns however many seconds remain
27+
// So movieLength % 60 divides the movieLength into whole minutes and returns however many seconds remain
2828

2929
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
3030

@@ -44,4 +44,4 @@ console.log(result);
4444
// The code is using basic mathematical operators, it works even with extremely small or large numbers, it works with 0, it even
4545
// works with negative numbers, although that is a little nonsensical, it may be better to return an error or undefined in that case
4646
// For very large numbers it would return a high number of hours, which one may want to then convert to days, or have a max limit
47-
// It all depends on what the use case for the code is
47+
// It all depends on what the use case for the code is

0 commit comments

Comments
 (0)