Skip to content

Commit 1c6ac2d

Browse files
committed
Restore Sprint‑1 files to original state
1 parent 1321b82 commit 1c6ac2d

14 files changed

Lines changed: 21 additions & 76 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ let count = 0;
22

33
count = count + 1;
44

5-
//Line 3 takes the current value of count, adds 1 to it, and then uses the = operator to assign (store) the new value back into the count variable.
5+
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
6+
// Describe what line 3 is doing, in particular focus on what = is doing

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@ let firstName = "Creola";
22
let middleName = "Katherine";
33
let lastName = "Johnson";
44

5-
let initials = firstName[0] + middleName[0] + lastName[0];
6-
console.log(initials);
5+
// Declare a variable called initials that stores the first character of each string.
6+
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution.
7+
8+
let initials = ``;
9+
10+
// https://www.google.com/search?q=get+first+character+of+string+mdn
11+

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ 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 + 1);
20+
const dir = ;
21+
const ext = ;
2122

22-
const ext = filePath.slice(filePath.lastIndexOf("."));
23-
24-
console.log(`The dir part of ${filePath} is ${dir}`);
25-
console.log(`The ext part of ${filePath} is ${ext}`);
26-
27-
// https://www.google.com/search?q=slice+mdn
23+
// https://www.google.com/search?q=slice+mdn

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ const maximum = 100;
44
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
55

66
// In this exercise, you will need to work out what num represents?
7-
//num is a random whole number between the minimum and maximum values.
8-
97
// Try breaking down the expression and using documentation to explain what it means
10-
// Math.random() generates a random number that's greater than or equal to 0 and less than 1
11-
// Math.floor() rounds a number down to the nearest whole number
12-
138
// It will help to think about the order in which expressions are evaluated
149
// Try logging the value of num and running the program several times to build an idea of what the program is doing
15-
console.log(num);
16-
//I have run it several times and I saw that the number is changing each time.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
//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?
1+
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?

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// trying to create an age variable and then reassign the value by 1
22

3-
let age = 33;
3+
const age = 33;
44
age = age + 1;
5-
6-
console.log(age);

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// Currently trying to print the string "I was born in Bolton" but it isn't working...
22
// what's the error ?
33

4-
const cityOfBirth = "Bolton";
54
console.log(`I was born in ${cityOfBirth}`);
6-
7-
//The error is that cityOfBirth is used before it is declared. The console.log runs before the variable exists.
5+
const cityOfBirth = "Bolton";

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

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

4-
console.log(`The last 4 digits of the card number are ${last4Digits}`);
5-
64
// The last4Digits variable should store the last 4 digits of cardNumber
75
// However, the code isn't working
86
// Before running the code, make and explain a prediction about why the code won't work
97
// Then run the code and see what error it gives.
108
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
119
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
12-
13-
//When I ran the code I got: TypeError: cardNumber.slice is not a function
14-
//I understand this happens because .slice() only works on strings, not numbers
15-
//To fix this I converted the number into a string so .slice() works

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
const TwelveHourClockTime = "8:53pm";
2-
const TwentyFourHourClockTime = "20:53";
3-
4-
console.log(TwelveHourClockTime);
5-
console.log(TwentyFourHourClockTime);
6-
7-
// The original code caused an error because variable names cannot start with a number.
8-
// I fixed the error by renaming the variables so they start with letters instead of numbers.
9-
//The code runs correctly and prints both time formats.
1+
const 12HourClockTime = "8:53pm";
2+
const 24hourClockTime = "20:53";

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ let carPrice = "10,000";
22
let priceAfterOneYear = "8,543";
33

44
carPrice = Number(carPrice.replaceAll(",", ""));
5-
priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));
5+
priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));
66

77
const priceDifference = carPrice - priceAfterOneYear;
88
const percentageChange = (priceDifference / carPrice) * 100;
@@ -12,19 +12,11 @@ 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-
// There are 3 function calls in this file.
16-
// They are on lines 4, 5, 10.
1715

1816
// 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?
19-
// The error is coming from line 5. This happens because there is a syntax error in the replaceAll function call.
20-
// I can fix this problem by adding the missing comma between the arguments.
2117

2218
// c) Identify all the lines that are variable reassignment statements
23-
// The variable reassignment statements are on lines 4 and 5.
2419

2520
// d) Identify all the lines that are variable declarations
26-
// The variable declarations are on lines 1, 2, 6, and 7.
2721

2822
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
29-
// The expression first removes all commas from the price string.
30-
// Then converts the cleaned string into a number so it can be used in calculations.

0 commit comments

Comments
 (0)