Skip to content

Commit 19ad2a1

Browse files
committed
Fixed syntax explanations and improved code comments
1 parent 288786a commit 19ad2a1

File tree

7 files changed

+20
-17
lines changed

7 files changed

+20
-17
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ console.log(count);
77
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
88
// Describe what line 3 is doing, in particular focus on what = is doing
99

10-
// Line 3 is updating the value of the count variable.
11-
// The = operator is an assignment operator, which assigns the value on the right (count + 1) to the variable on the left (count).
10+
// Line 3 increments the value of the count variable by 1.
11+
// The = operator assigns the result of (count + 1) back to count.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ const ext = filePath.slice(filePath.lastIndexOf(".")) ;
2222

2323
console.log("dir:", dir);
2424
console.log("ext:", ext);
25-
// https://www.google.com/search?q=slice+mdn
25+
// https://www.google.com/search?q=slice+mdns

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;
55

66
console.log(num);
77

8-
// In this exercise, you will need to work out what num represents?
8+
// In this exercise, you will need to work out what num represents?
99
// num represents a random whole number between the minimum and maximum values.
1010

1111
// Try breaking down the expression and using documentation to explain what it means
1212
// It will help to think about the order in which expressions are evaluated
1313
// Try logging the value of num and running the program several times to build an idea of what the program is doing
1414

15-
//Step 1 Generate a random decimal between 0 and 1
16-
//step 2 multiplys the random decimal by 100 - 1 = 99 + 1 = 100
17-
//step 3 math.floor makes it a whole number between 0 and 99
18-
//step 4 adds 1 to make it a whole number between 1 and 100
15+
// Step 1: Math.random() returns a decimal in [0, 1) (includes 0, excludes 1)
16+
// Step 2: Multiply by 100 -> value is in [0, 100)
17+
// Step 3: Math.floor(...) converts it to an integer in [0, 99]
18+
// Step 4: Add 1 -> integer in [1, 100]

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// Currently trying to print the string "I was born in Bolton" but it isn't working...
2-
// what's the error ? The error is that the string is not being printed to the console because there is no console.log statement to output it.
2+
// what's the error ? The error was cannot acess 'cityofBirth' before initialization.
3+
// This happpend becouse CityofBirth was declared with a const but was used before its decleration.
4+
5+
const cityofBirth = "Bolton";
6+
console.log(`I was born in ${cityofBirth}`);
7+
38

4-
console.log("I was born in Bolton");
5-
const cityOfBirth = "Bolton";

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ console.log(`The percentage change is ${percentageChange}`);
1717
// line 10 has a function call
1818

1919
// 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-
// I have spotted the error in line 5 becouse there was a missing comma inside the brackets.
20+
// I have spotted the error on line 5 there was a missing coma between the two arguments of replaceAll() specifically between "," and "".
2121

2222
// c) Identify all the lines that are variable reassignment statements
2323
// Line 4 and line 5 are variable reassignment statements.
@@ -29,5 +29,5 @@ console.log(`The percentage change is ${percentageChange}`);
2929
// line 8
3030

3131
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
32-
// The purpose of this expression is to remove the commas from the string value using the replaceAll().
32+
// replaceAll() removes commas and Number() converts the cleaned string into a number.
3333

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ 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-
// There is 6 Variable declarations
15+
// There is 6 Variable declarations
1616
// Line 1 , Line 3 , Line 4 , Line 6 , Line 7 , Line 9
1717

1818
// b) How many function calls are there?
@@ -26,8 +26,8 @@ console.log(result);
2626
// Line 4 removes the leftover seconds, then devides by 60.
2727
// then divides the result by 60 to calculate the total full minutes.
2828

29-
// e) What do you think the variable result represents? Can you think of a better name for this variable?
30-
// Result is a formatted time string in hours minutes and seconds.
29+
// e) What do you think the variable result represents? Can you think of a better name for this variable?
30+
// Result is a formatted time string in hours, minutes and seconds. A better name for this varible could be formattedTime.
3131

3232
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
3333
// I tested diffrent positive numbers and the code work correctly.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ Now try invoking the function `prompt` with a string input of `"What is your nam
1616

1717
What effect does calling the `prompt` function have? The prompt function displays a popup box asking you to enter a text and pausing the page until you click ok or cancel.
1818

19-
What is the return value of `prompt`? Prompt returns the text entered by the user as a string if the user clicks cancel.
19+
What is the return value of `prompt`? Prompt returrns the text enterend by the user as a string if the user clicks OK, and returns null if the user clicks cancel.

0 commit comments

Comments
 (0)