Skip to content

Commit 99f9720

Browse files
authored
restoring sprint 1 folder from cyf main
1 parent 958730d commit 99f9720

File tree

12 files changed

+9
-93
lines changed

12 files changed

+9
-93
lines changed

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +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-
Answer
8-
// Line 3; when we the right side first count in the right side is considered as 0 so 0+1 will be 1.
9-
// But the = sign does not mean the mathematical equal, its function is to take the result on the right and store it on the left.
10-
// Therefore if we write the same code in next line the result is not one but 2

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +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 = `${firstName[0]}${middleName[0]}${lastName[0]}`;
8+
let initials = ``;
99

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

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +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);
21-
const lastDotIndex = base.lastIndexOf(".");
22-
const ext = base.slice(lastDotIndex + 1);
23-
20+
const dir = ;
21+
const ext = ;
2422

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

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,3 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
77
// Try breaking down the expression and using documentation to explain what it means
88
// It will help to think about the order in which expressions are evaluated
99
// Try logging the value of num and running the program several times to build an idea of what the program is doing
10-
11-
// Answer
12-
13-
// 1.
14-
// The num in this scenario represent any integer between 1 and 100
15-
16-
// 2.
17-
// Math.floor: rounds the number down to the nearest whole number which means it ignores the number to the right of the point. eg. 4.7=4
18-
// Math.random is a js code that returns any random number that is greater than or equal to 0 and less than 1
19-
//* is multiplication
20-
// maximum is the maximum given number, in this case 100
21-
//- is a subtraction
22-
// minimum is the minimum given number, in this case 1
23-
//(maximum - minimum +1) this is subtracting the minimum number from the maximum and add 1, in this case (100-1+1)=100
24-
//+ minimum: this turns the value by adding 1 to the whole equation.
25-
26-
//3.
27-
28-
console.log(num)

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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +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-
console.log(age)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +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-
5-
const cityOfBirth = "Bolton";
64
console.log(`I was born in ${cityOfBirth}`);
5+
const cityOfBirth = "Bolton";

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +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-
//Answer
12-
13-
// This code is not working because slice() is working with "string" or "arrays" but not with numbers. and cardNumber is a number.
14-
// So the error is "TypeError:cardNumber.slice is not a function"\
15-
// slice() didn't recognize the number as I expected before.
16-
17-
const cardNumber = 4533787178994213;
18-
const last4Digits = String(cardNumber).slice(-4);
19-
console.log(last4Digits)

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
const 12HourClockTime = "20:53";
2-
const 24hourClockTime = "08:53";
3-
// the 12 and 24 are changing position
4-
const 24HourClockTime = "20:53";
5-
const 12hourClockTime = "08:53";
2+
const 24hourClockTime = "08:53";

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

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +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-
// There are five functions calls.
17-
//carPrice.replaceAll(",", "")
18-
//Number(carPrice.replaceAll(",", ""))
19-
//priceAfterOneYear.replaceAll("," "")
20-
//Number(priceAfterOneYear.replaceAll("," ""))
21-
//console.log(`The percentage change is ${percentageChange}`)
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-
// When I run the code the error is "syntaxError: missing ) after argument list.
26-
// The error comes from line 5
27-
// The error occurs due to the missing coma between the two strings in the replaceAll() call.
28-
// Add coma between the two strings "priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));"
29-
3018
// c) Identify all the lines that are variable reassignment statements
3119

32-
// there are to lines that state variable reassignment
33-
// carPrice = Number(carPrice.replaceAll(",", ""));
34-
// priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," ""));
35-
3620
// d) Identify all the lines that are variable declarations
3721

38-
// There are fore variable declarations (line 1, line 2, line 7, line 8)
39-
// let carPrice = "10,000";
40-
// let priceAfterOneYear = "8,543";
41-
// const priceDifference = carPrice - priceAfterOneYear;
42-
// const percentageChange = (priceDifference / carPrice) * 100;
43-
44-
4522
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
46-
47-
// carprice at line 1 is a string in order to calculate for the next line of codes you have to change the string ti number.
48-
// carPrice.replaceAll(",","")). delete the coma in between the number (e.g from "10,000" to "10000")
49-
// number() change the string to number ("10000" to 10000)

0 commit comments

Comments
 (0)