Skip to content

Commit 715631a

Browse files
committed
Format with prettier
1 parent 8e63d7e commit 715631a

8 files changed

Lines changed: 22 additions & 13 deletions

File tree

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ const lastName = "Johnson";
77

88
const initials = `firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0)`;
99

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

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ 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,filePath.indexOf(base));
21-
const ext = filePath.slice(-(filePath.length-filePath.indexOf(".")));
22-
console.log(ext)
20+
const dir = filePath.slice(0, filePath.indexOf(base));
21+
const ext = filePath.slice(-(filePath.length - filePath.indexOf(".")));
22+
console.log(ext);
2323

24-
// https://www.google.com/search?q=slice+mdn
24+
// 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
@@ -14,5 +14,5 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
1414
//(maximum - minimum + 1) gives in this case 100
1515
//So then Math.random() * (maximum - minimum + 1) gives a number between 0 and 99
1616
//Math.random() * (maximum - minimum + 1) gives a number between 1 and 100
17-
//and thus Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; gives a whole rounded
17+
//and thus Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; gives a whole rounded
1818
//down number

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ const age = 33;
44
age = age + 1;
55

66
//TypeError: Assignment to constant variable.
7-
//Age is constant so can't be reassigned
7+
//Age is constant so can't be reassigned
88
//To fix, change const to let, so line 3 becomes:
9-
//let age = 33;
9+
//let age = 33;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ const cityOfBirth = "Bolton";
66

77
//ReferenceError: Cannot access 'cityOfBirth' before initialization
88
//Trying to use cityOfBirth before it's defined
9-
//To fix, put line 5 before line 4, so it is initialised before use
9+
//To fix, put line 5 before line 4, so it is initialised before use

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const cardNumber = 4533787178994213;
22
const last4Digits = cardNumber % 10000;
3-
console.log(last4Digits)
3+
console.log(last4Digits);
44

55
// The last4Digits variable should store the last 4 digits of cardNumber
66
// However, the code isn't working
@@ -10,4 +10,4 @@ console.log(last4Digits)
1010
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
1111

1212
//TypeError: cardNumber.slice is not a function
13-
//cardNumber is an integer, and slice is a string method, so slice doesn't work on cardNumber
13+
//cardNumber is an integer, and slice is a string method, so slice doesn't work on cardNumber

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const movieLength = 8784; // length of movie in seconds
1+
const movieLength = 5; // length of movie in seconds
22

33
const remainingSeconds = movieLength % 60;
44
const totalMinutes = (movieLength - remainingSeconds) / 60;
@@ -12,14 +12,24 @@ console.log(result);
1212
// For the piece of code above, read the code and then answer the following questions
1313

1414
// a) How many variable declarations are there in this program?
15+
//5
1516

1617
// b) How many function calls are there?
18+
//1
1719

1820
// c) Using documentation, explain what the expression movieLength % 60 represents
1921
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
22+
//% is the modulo operator, which gives the remainder after operand.
23+
//so in this case, the remainder of movieLength/60,
24+
// the number of seconds not in a whole minute
2025

2126
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
27+
//Take the total number of seconds in the move, minus the remainder of movieLength/60 to give
28+
//a number that divides exactly by 60, then divide that number by 60. it converts the
29+
// time into minutes
2230

2331
// e) What do you think the variable result represents? Can you think of a better name for this variable?
32+
//The number of whole minutes in the movie. numFullMinutes
2433

2534
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
35+
//Yes the math is fine and works with all numbers.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ console.log(`£${pounds}.${pence}`);
4848
// 5. const pence = paddedPenceNumberString
4949
// .substring(paddedPenceNumberString.length - 2)
5050
// .padEnd(2, "0");
51-
// Takes the substring starting at the total length-2, to the end. Essentially taking the
51+
// Takes the substring starting at the total length-2, to the end. Essentially taking the
5252
// last 2 digits
5353
// Then adds 0 to the beginning so it is at least 2 characters long

0 commit comments

Comments
 (0)