Skip to content

Commit 9e45bc7

Browse files
committed
format Sprint-2 with Prettier
1 parent fa97c40 commit 9e45bc7

12 files changed

Lines changed: 58 additions & 51 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ const 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-
const initials = firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0);
8+
const initials =
9+
firstName.charAt(0) + middleName.charAt(0) + lastName.charAt(0);
910
console.log(initials);
1011

1112
// 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
@@ -20,5 +20,4 @@ console.log(`The base part of ${filePath} is ${base}`);
2020
const dir = filePath.slice(0, lastSlashIndex);
2121
const ext = filePath.slice(filePath.lastIndexOf(".") + 1);
2222

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

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
77
//num represents a randomly generated whole number between 1 and 100.
88

99
// Try breaking down the expression and using documentation to explain what it means
10-
// Math.random() generates a random decimal number greater than or equal to 0 and less than 1. Multiplying by 100 gives a number between 0 and up to, but not including 100.
11-
// Math.floor() always rounds down and returns the largest integer less than or equal to a given number in this case between 0 and 99. Finally, adding 1 changes the range to 1–100.
12-
// Math.floor(Math.random() * (maximum - minimum + 1))
13-
// Math.floor(Math.random() * (100 - 1 + 1))
14-
// Math.floor(Math.random() * 100)
15-
// Math.random give any random number between 0 to 1 example 0.225 * 100 = 22.5
16-
// Math.floor rounds that number to a whole number so 22.5 will become 22
17-
// (22) + minimum
18-
// 22 + 1
19-
// 23
20-
10+
// Math.random() generates a random decimal number greater than or equal to 0 and less than 1. Multiplying by 100 gives a number between 0 and up to, but not including 100.
11+
// Math.floor() always rounds down and returns the largest integer less than or equal to a given number in this case between 0 and 99. Finally, adding 1 changes the range to 1–100.
12+
// Math.floor(Math.random() * (maximum - minimum + 1))
13+
// Math.floor(Math.random() * (100 - 1 + 1))
14+
// Math.floor(Math.random() * 100)
15+
// Math.random give any random number between 0 to 1 example 0.225 * 100 = 22.5
16+
// Math.floor rounds that number to a whole number so 22.5 will become 22
17+
// (22) + minimum
18+
// 22 + 1
19+
// 23
20+
2121
// It will help to think about the order in which expressions are evaluated
2222
// Try logging the value of num and running the program several times to build an idea of what the program is doing

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

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
let age = 33;
77
age = age + 1;
8-
console.log(age);
8+
console.log(age);

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

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

44
const cardNumber = "4533787178994213";
55
const last4Digits = cardNumber.slice(-4);
6-
console.log(last4Digits)
6+
console.log(last4Digits);
77

88
// The last4Digits variable should store the last 4 digits of cardNumber
99
// However, the code isn't working
1010

1111
// Before running the code, make and explain a prediction about why the code won't work
12-
//slice() not work with number
12+
//slice() not work with number
1313

14-
// Then run the code and see what error it gives.
15-
//cardNumber.slice is not a function
14+
// Then run the code and see what error it gives.
15+
//cardNumber.slice is not a function
1616

17-
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
17+
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
1818
// Then try updating the expression last4Digits is assigned to, in order to get the correct value

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ console.log(`The percentage change is ${percentageChange}`);
1212
// Read the code and then answer the questions below
1313

1414
// a) How many function calls are there in this file? Write down all the lines where a function call is made
15-
// 5 function calls
16-
// -Number(carPrice.replaceAll(",", ""))
17-
// -replaceAll(",", "")
18-
// -Number(priceAfterOneYear.replaceAll("," ""))
19-
// -replaceAll("," "")
20-
// -console.log(`The percentage change is ${percentageChange}`)
15+
// 5 function calls
16+
// -Number(carPrice.replaceAll(",", ""))
17+
// -replaceAll(",", "")
18+
// -Number(priceAfterOneYear.replaceAll("," ""))
19+
// -replaceAll("," "")
20+
// -console.log(`The percentage change is ${percentageChange}`)
2121
// 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?
22-
// -Line 5
23-
// -missing ) after argument list
24-
// -why: replaceAll() needs two arguments separated by a comma.
25-
// -fix: by adding comma replaceAll(",", "")
22+
// -Line 5
23+
// -missing ) after argument list
24+
// -why: replaceAll() needs two arguments separated by a comma.
25+
// -fix: by adding comma replaceAll(",", "")
2626
// c) Identify all the lines that are variable reassignment statements
27-
// line 4 and 5
27+
// line 4 and 5
2828

2929
// d) Identify all the lines that are variable declarations
30-
// line 1,2,7 and 8
30+
// line 1,2,7 and 8
3131
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
32-
// -First removing the comma "10,000"
33-
// -Second convert string into number 10000
32+
// -First removing the comma "10,000"
33+
// -Second convert string into number 10000

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ 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-
// 6
15+
// 6
1616
// b) How many function calls are there?
17-
// 1
17+
// 1
1818
// c) Using documentation, explain what the expression movieLength % 60 represents
1919
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
20-
// Remainder operator : calculates the remainder after dividing the movie length in seconds by 60
20+
// Remainder operator : calculates the remainder after dividing the movie length in seconds by 60
2121
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
22-
// It takes the remaining seconds away from the total movie length and divides by 60 to turn the seconds into minutes.
22+
// It takes the remaining seconds away from the total movie length and divides by 60 to turn the seconds into minutes.
2323

2424
// e) What do you think the variable result represents? Can you think of a better name for this variable?
25-
// - It represents the movie duration in hours, minutes, and seconds.
26-
// - const movieDuration
25+
// - It represents the movie duration in hours, minutes, and seconds.
26+
// - const movieDuration
2727
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
28-
// The code works with positive whole numbers for movieLength and changes them into hours, minutes, and seconds. Decimal or negative numbers may not give the correct result.
28+
// The code works with positive whole numbers for movieLength and changes them into hours, minutes, and seconds. Decimal or negative numbers may not give the correct result.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ 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
const pounds = paddedPenceNumberString.substring(
1010
0,
11-
paddedPenceNumberString.length - 2
11+
paddedPenceNumberString.length - 2,
1212
);
1313

1414
const pence = paddedPenceNumberString
@@ -41,4 +41,4 @@ console.log(`£${pounds}.${pence}`);
4141
// .substring(paddedPenceNumberString.length - 2)
4242
// .padEnd(2, "0"); //gets the last two digits to find the pence.
4343

44-
// 6. console.log(`£${pounds}.${pence}`); //Combines the pounds and pence and print the final price as £3.99
44+
// 6. console.log(`£${pounds}.${pence}`); //Combines the pounds and pence and print the final price as £3.99

Sprint-2/4-stretch-explore/chrome.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ Let's try an example.
88
In the Chrome console, invoke the function `alert` with one argument, the string `"Hello world!"`;
99

1010
What effect does calling the `alert` function have?
11+
1112
- A popup with chrome:/new-tab-page says "hello world"
1213

1314
Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`.
1415

1516
What effect does calling the `prompt` function have?
17+
1618
- A popup with chrome:/new-tab-page says "What is your name?" with a text box to type your name.
1719

1820
What is the return value of `prompt`?
21+
1922
- "myname" which is the value that i entered.

0 commit comments

Comments
 (0)