Skip to content

Commit da83341

Browse files
committed
Delete Sprint-1 folder
1 parent d34a28d commit da83341

File tree

14 files changed

+18
-481
lines changed

14 files changed

+18
-481
lines changed

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,3 @@ count = count + 1;
44

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
7-
8-
/**
9-
* Line 3 increase the count variable by 1 then assign the result in right hand side to count variable
10-
*/
11-
12-
console.log('Value of count variable: ', count)
13-

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ 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 = ``;
9-
let initials = `${firstName.charAt(0)}${middleName.charAt(0)}${lastName.charAt(0)}`;
10-
console.log(initials);
8+
let initials = ``;
119

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

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,9 @@ const base = filePath.slice(lastSlashIndex + 1);
1515
console.log(`The base part of ${filePath} is ${base}`);
1616

1717
// Create a variable to store the dir part of the filePath variable
18-
const dir = filePath.slice(0, lastSlashIndex);
19-
2018
// Create a variable to store the ext part of the variable
21-
const lastDotIndex = filePath.lastIndexOf(".");
22-
const ext = filePath.slice(lastDotIndex);
23-
24-
console.log(`The dir part of ${filePath} is ${dir}`);
25-
console.log(`The ext part of ${filePath} is ${ext}`);
2619

20+
const dir = ;
21+
const ext = ;
2722

28-
// 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 & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,7 @@ const maximum = 100;
33

44
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
55

6-
console.log(num);
7-
86
// In this exercise, you will need to work out what num represents?
97
// Try breaking down the expression and using documentation to explain what it means
108
// It will help to think about the order in which expressions are evaluated
119
// Try logging the value of num and running the program several times to build an idea of what the program is doing
12-
13-
/**
14-
* Step 1: Math.random()
15-
16-
* This generates a random decimal number between 0 (inclusive) and 1 (exclusive).
17-
* Example: 0.3728, 0.9134, etc.
18-
19-
* Step 2: (maximum - minimum + 1)
20-
21-
* This calculates the range of possible numbers you want.
22-
* Here: 100 - 1 + 1 = 100
23-
* So, we’re creating a range that includes both 1 and 100.
24-
25-
* Step 3: Math.random() * (maximum - minimum + 1)
26-
27-
* This scales the random decimal to the range.
28-
* Example: If Math.random() returns 0.3728,
29-
* 0.3728 * 100 = 37.28
30-
31-
* Step 4: Math.floor(...)
32-
33-
* Math.floor() rounds down to the nearest whole number.
34-
* So 37.28 becomes 37.
35-
36-
* Step 5: + minimum
37-
38-
* Because the range started from 0, we add minimum (which is 1) to shift it to the correct range.
39-
40-
* Example: 37 + 1 = 38.
41-
42-
* So what does num represent?
43-
* num is a random integer between 1 and 100 (inclusive).
44-
* Every time you run the program, you’ll get a different number in that range.
45-
46-
* Running it several times — you’ll see numbers like 27, 99, 7, 100, etc.
47-
48-
*/
49-

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

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +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?
3-
4-
/** If you have lines that are just instructions or notes for humans and you don’t want the computer to execute them, you can turn them into comments.
5-
6-
In JavaScript, there are two ways to write comments:
7-
8-
1. Single-line comment
9-
10-
Use // at the start of a line.
11-
Everything after // is ignored by the computer.
12-
13-
Example:
14-
15-
// This line explains what the code does
16-
const num = 8;
17-
18-
2. Multi-line comment
19-
20-
Use \ /* ... *\ / to wrap several lines.
21-
22-
Example:
23-
This section is just instructions
24-
The computer will ignore everything between these symbols
25-
26-
const num = 5;
27-
28-
*/
29-
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 & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
// trying to create an age variable and then reassign the value by 1
22

3-
// change keyword 'const' to 'let'
4-
let age = 33;
3+
const age = 33;
54
age = age + 1;
6-
7-
console.log(age);
8-

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +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-
// this is a very common JavaScript error related to variable hoisting and the temporal dead zone.
5-
// Simply declare the variable before you use it
6-
7-
const cityOfBirth = "Bolton";
84
console.log(`I was born in ${cityOfBirth}`);
9-
5+
const cityOfBirth = "Bolton";

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

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,9 @@
1-
// const cardNumber = 4533787178994213;
2-
// const last4Digits = cardNumber.slice(-4);
1+
const cardNumber = 4533787178994213;
2+
const last4Digits = cardNumber.slice(-4);
33

44
// The last4Digits variable should store the last 4 digits of cardNumber
55
// However, the code isn't working
66
// Before running the code, make and explain a prediction about why the code won't work
77
// Then run the code and see what error it gives.
88
// Consider: Why does it give this error? Is this what I predicted? If not, what's different?
99
// Then try updating the expression last4Digits is assigned to, in order to get the correct value
10-
11-
/**
12-
*Prediction: Why won’t this code work?
13-
const cardNumber = 4533787178994213;
14-
const last4Digits = cardNumber.slice(-4);
15-
16-
17-
The issue is that .slice() is a string method, but cardNumber here is a number — not a string.
18-
So when the code runs, JavaScript will say something like:
19-
20-
TypeError: cardNumber.slice is not a function
21-
22-
That’s because .slice() only works on strings or arrays — and numbers don’t have that method.
23-
24-
Fixing the problem
25-
26-
To use .slice(), we need to convert the number into a string first:
27-
28-
Now it works!
29-
*/
30-
31-
const cardNumber = 4533787178994213;
32-
const last4Digits = cardNumber.toString().slice(-4);
33-
console.log(last4Digits); // "4213"
34-

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

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,2 @@
1-
// const 12HourClockTime = "20:53";
2-
// const 24hourClockTime = "08:53";
3-
4-
/**
5-
* In javascript variable can't start with a number
6-
* Can contain letters, digits (but not at the start), underscore _, and dollar signs $
7-
*
8-
* const 12HourClockTime = "20:53"; will cause a SyntaxError because variable names can't begin with a number.
9-
*
10-
* To fix it by changing the name to start with a letter.
11-
*/
12-
13-
const twelveHourClockTime = "08:53";
14-
const twentyFourClockTime = "20:53";
15-
16-
console.log(twelveHourClockTime);
17-
console.log(twentyFourClockTime);
18-
1+
const 12HourClockTime = "20:53";
2+
const 24hourClockTime = "08:53";

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

Lines changed: 1 addition & 31 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;
@@ -13,40 +13,10 @@ console.log(`The percentage change is ${percentageChange}`);
1313

1414
// a) How many function calls are there in this file? Write down all the lines where a function call is made
1515

16-
// Function calls and their line numbers
17-
// line 3 - carPrice.replaceAll(",", "") - Callls replaceAll() on the string to remove commas
18-
// line 3 - Number(...) - Converts the resulting string to a number
19-
// line 4 - priceAfterOneYear.replaceAll("," "") - Syntax error here - Intendend to replaceAll() but missing a comma between arguments
20-
// line 8 - console.log(...) - Prints to console
21-
// // Total intended function calls: 5
22-
2316
// 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?
2417

25-
// priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));
26-
// Error: SyntaxError: missiong ) after argument list
27-
// Reason:
28-
// There's a missing comma between the arguments of replaceAll.
29-
// The correct syntax should be:
30-
// priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));
31-
3218
// c) Identify all the lines that are variable reassignment statements
3319

34-
// These are the lines where variables that were already declared are assigned a new value:
35-
// carPrice = Number(carPrice.replaceAll(",", "");
36-
// priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));
37-
// Reassignments: Lines 3 and 4
38-
3920
// d) Identify all the lines that are variable declarations
4021

41-
// These are the lines where variables are first introduced:
42-
// let carPrice = "10,000";
43-
// let priceAfterOneYear = "8,543";
44-
// const priceDifference = carPrice - priceAfterOneYear;
45-
// const percentageChange = (priceDifference / carPrice) * 100;
46-
4722
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
48-
49-
// carPrice.replaceAll(",", "") - removes all commas from the string "10,000", then it becomes "10000"
50-
// Number("10000") - Converts the string "10000" into a numeric value 10000.
51-
// Purpose: To convert a formatted currency string (with commas) into a number that can be used for mathematical calculations.
52-

0 commit comments

Comments
 (0)