Skip to content

Commit 2cae221

Browse files
committed
Revert Sprint-1 files to base code
1 parent f7edaf1 commit 2cae221

14 files changed

Lines changed: 13 additions & 114 deletions

File tree

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +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-
The = served as the executer of the assignment operation.
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
// Declare a variable called initials that stores the first character of each string.
2-
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution.
3-
41
let firstName = "Creola";
52
let middleName = "Katherine";
63
let lastName = "Johnson";
74

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.
87

9-
function getInitials() {
10-
return `${firstName[0]}${middleName[0]}${lastName[0]}`;
11-
}
12-
13-
console.log(getInitials());
14-
15-
// Export the initials for testing instead of returning at top-level
16-
module.exports = getInitials;
17-
8+
let initials = ``;
189

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +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 = ; /Users/mitch/cyf/Module-JS1/week-1/interpret/
21-
const ext = ; file.txt;
20+
const dir = ;
21+
const ext = ;
2222

2323
// https://www.google.com/search?q=slice+mdn

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
const minimum = 1;
22
const maximum = 100;
33

4-
for (let i = 0; i < 5; i++) {
5-
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
6-
console.log(num);
7-
}
4+
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
85

96
// In this exercise, you will need to work out what num represents?
107
// Try breaking down the expression and using documentation to explain what it means

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +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-
To prevent the computer from executing these lines of code, you can comment them out,
5-
you can use `//` for single-line comments or `/* */` for multi-line comments, like i demonstated above.
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +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;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +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}`);
5+
const cityOfBirth = "Bolton";

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,3 @@ const last4Digits = cardNumber.slice(-4);
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-
PREDICTION:
12-
//the code wont work because the card number isnt in ("") and the computer wont be able to apply the .slice due to this.
13-
14-
THE ERROR:
15-
//cardNumber.slice is not a function
16-
17-
//YES! the error is what i predicted.
18-
19-
FIX:
20-
const cardnumber = "4533787178994213";
21-
const last4Digits = cardnumber.slice(-4);
22-
console.log(last4Digits);

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
const twelveHourClockTime = "8:53pm";
2-
const twentyFourHourClockTime = "20:53";
3-
4-
//The Error:
5-
//The code would not run because only a letter can follow the 'const' and 'let' declarations in javascript.
1+
const 12HourClockTime = "8:53pm";
2+
const 24hourClockTime = "20:53";

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +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-
//1. Line 5: carPrice.replaceAll(",", "")
16-
//2. Line 6: priceAfterOneYear.replaceAll(",", "")
17-
//3. Line 8: console.log(`The percentage change is ${percentageChange}`)
1815

1916
// 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?
20-
//The error is in line 5, the error is occurring because there was a comma missing here; ("," "").
2117

2218
// c) Identify all the lines that are variable reassignment statements
23-
//carPrice = Number(carPrice.replaceAll(",", ""));
24-
//priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",",""));
2519

2620
// d) Identify all the lines that are variable declarations
27-
//let carPrice = "10,000";
28-
//let priceAfterOneYear = "8,543";
29-
//const priceDifference = carPrice - priceAfterOneYear;
30-
//const percentageChange = (priceDifference / carPrice) * 100;
31-
3221

3322
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
34-
//The expression is converting the string representation of the car price to a number by first removing the comma.
35-
36-
//Purpose:
37-
//To allow the computer identify the value of the car price as a number so that it can be used in calculations.

0 commit comments

Comments
 (0)