Skip to content

Commit b6395cf

Browse files
committed
updated files as per review instructions
1 parent 95ef210 commit b6395cf

10 files changed

Lines changed: 16 additions & 20 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ count = count + 1;
55
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
66
// Describe what line 3 is doing, in particular focus on what = is doing
77

8-
//Answer: The = means assignment. The value of count is 0 but it increments by 1
8+
//Answer: The = means assignment. The value of count is 0 but it increments by 1

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ const firstName = "Creola";
22
const middleName = "Katherine";
33
const lastName = "Johnson";
44

5-
65
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution.
76

87
const initials = firstName[0] + middleName[0] + lastName[0];
9-
console.log(initials)
8+
console.log(initials);
109

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

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@ const ext = base.slice(base.lastIndexOf("."));
2323
console.log(`The dir part of ${filePath} is ${dir}`);
2424
console.log(`The ext part of ${base} is ${ext}`);
2525

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

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const maximum = 100;
33

44
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
55
// (0.68 * 100 ) + 1
6-
console.log(num)
6+
console.log(num);
77

88
// In this exercise, you will need to work out what num represents?
99
// Try breaking down the expression and using documentation to explain what it means
@@ -13,8 +13,9 @@ console.log(num)
1313
// Answer: For calculations i utilised BODMAS formula solving numbers in brackets first, multiplication, subtraction and addition
1414
// I used 0.68 for math.floor(random number) + 1
1515
// Sum = 69
16-
// 1.num represents a number which is an Integer that is greater or equal to 1
16+
// 1.num is a random whole number from 1 to 100.
1717
// 2.start by (maximum-minimum +1) which the output is 100
1818
// 3.math.random()*100 returns random number between 0 and 100. Any random number less that 1 can be selected then multiplied by 100
1919
// 4.math.floor() gives out the largest integer which is less than or equal to the given number which is a decimal
20-
// The output is displayed in console log
20+
// The output is displayed in console log
21+
// 5. + minimum adds 1. So the range 0 to 99 becomes 1 to 100.

‎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-
// I have commented out the lines. The computer removes commented lines from code compilation
4+
// I have commented out the lines. The computer removes commented lines from code compilation

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ const cityOfBirth = "Bolton";
55
console.log(`I was born in ${cityOfBirth}`);
66

77
// The error is ReferenceError: Cannot access 'cityOfBirth' before initialization
8-
// Answer: I switched the order by declaring the const first before calling /printing
8+
// Answer: I switched the order by declaring the const first before calling /printing

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const cardNumber = "4533787178994213";
2-
const last4Digits = cardNumber.slice(-4);
1+
const cardNumber = 4533787178994213;
2+
const last4Digits = String(cardNumber).slice(-4);
33
console.log(last4Digits);
44

55
// The last4Digits variable should store the last 4 digits of cardNumber
@@ -12,4 +12,4 @@ console.log(last4Digits);
1212
//Prediction was the code would run successfully without error although with the wrong results due to absence of syntax errors in the file
1313
// Error returned: TypeError: cardNumber.slice is not a function
1414
// Lesson learnt here; slice method is only available for strings or arrays not numbers
15-
// So converted the cardNumber into a string first
15+
// I used String() on line 2 to turn the number into a string

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ console.log(`The percentage change is ${percentageChange}`);
1414
// a) How many function calls are there in this file? Write down all the lines where a function call is made
1515
// 5
1616
// * number() and .replaceAll() in line 4
17-
// * number() and .replaceAll()in line 4
18-
// console.log()
17+
// * number() and .replaceAll()in line 5
18+
// console.log() is on line 10
1919
// 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?
2020
//b) error = SyntaxError: missing ) after argument list
2121
// (",", ",")); - added , between quoted values

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ console.log(result);
1818
// 1 (console.log())
1919
// c) Using documentation, explain what the expression movieLength % 60 represents
2020
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
21-
// It means 60 % remainder of Movie length
2221
// 24 seconds
2322

2423
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
@@ -27,7 +26,7 @@ console.log(result);
2726

2827
// e) What do you think the variable result represents? Can you think of a better name for this variable?
2928
// I think its the total movie length with a timer. Based on research it appears to be template literal variable as it mixes static text with dynamic data. Sorry I don't fully understand this bit yet
30-
// It represents the MovieDuration
29+
// It represents the movieDuration
3130

3231
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
3332
//any number greater than zero returns a valid positive hour, minute or seconds result. Changing the length to 0 returns 0:0:0. Any negative length returns negative values

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ console.log(`£${pounds}.${pence}`);
2525

2626
// To begin, we can start with
2727
// 1. const penceString = "399p": initialises a string variable with the value "399p"
28-
// 2. const penceStringWithoutTrailingP = penceString.substring(0): sets penceStringWithoutTRailingP = 399.0 - penceString -1 = 39
2928
// 2. P will be dropped
3029
// 3. const paddedPenceNumberString - ensures the figure is 3 characters to taking us back to 399
3130
// 4 const pounds - removes 2 characters from the amount = 3
32-
// 5. const pence - adds the amount by 2 characters taking us back to either 39 or 99
33-
// 5. const pence is initialised in 2 methods 1)extracts the string from index 2)adds 0 hence = 99
31+
// 5. substring(paddedPenceNumberString.length - 2) takes the last 2 characters of 399 which is 99. padEnd(2, "0") adds zeros for strings shorter than 2 characters. In this case, 99 is already 2 characters so nothing is added.
3432
// 6. console displays the figures in pounds and pence = 3.99

0 commit comments

Comments
 (0)