Skip to content

Commit 88f3c8c

Browse files
committed
Refactor comments to multi-line style for clarity and consistency across multiple files
1 parent aa69c9f commit 88f3c8c

7 files changed

Lines changed: 41 additions & 41 deletions

File tree

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ let count = 0;
22

33
count = count + 1;
44

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
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
77
8-
// The = served as the executer of the assignment operation.
8+
The = served as the executer of the assignment operation.*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
//We don't want the computer to run these 2 lines - how can we solve this problem?
33

44
/* 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.
5+
you can use "//" for single-line comments or "slash-star... slash-star" for multi-line comments */

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
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
1010

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.
11+
/*PREDICTION:
12+
the code wont work because the card number is not in ("") and the computer wont be able to apply the .slice due to this.
1313
14-
//THE ERROR:
15-
//cardNumber.slice is not a function
14+
THE ERROR:
15+
cardNumber.slice is not a function
1616
17-
//YES! the error is what i predicted.
17+
YES! the error is what i predicted.*/
1818

1919
//FIX:
2020
const cardnumber = "4533787178994213";

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const twelveHourClockTime = "8:53pm";
22
const twentyFourHourClockTime = "20:53";
33

4-
//The Error:
5-
//The code would not run because only a letter can follow the 'const' and 'let' declarations in javascript.
4+
/*The Error:
5+
The code would not run because only a letter can follow the 'const' and 'let' declarations in javascript.*/

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@ 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}`)
15+
/*1. Line 5: carPrice.replaceAll(",", "")
16+
2. Line 6: priceAfterOneYear.replaceAll(",", "")
17+
3. Line 8: console.log(`The percentage change is ${percentageChange}`)*/
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?
2020
//The error is in line 5, the error is occurring because "comma missing "," and "" for priceAfterOneYear.replaceAll("," "") function call.
2121

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

2626
// 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;
27+
/*let carPrice = "10,000";
28+
let priceAfterOneYear = "8,543";
29+
const priceDifference = carPrice - priceAfterOneYear;
30+
const percentageChange = (priceDifference / carPrice) * 100;*/
3131

3232

3333
// 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.
34+
/*The expression is converting the string representation of the car price to a number by first removing the comma.
3535
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.
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.*/

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ 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-
//1.movieLength
16-
//2.remainingSeconds
17-
//3.totalMinutes
18-
//4.remainingMinutes
19-
//5.totalHours
20-
//6.result
15+
/*1.movieLength
16+
2.remainingSeconds
17+
3.totalMinutes
18+
4.remainingMinutes
19+
5.totalHours
20+
6.result */
2121

2222
// b) How many function calls are there?
2323
//1. Line 10: console.log(result)
@@ -26,19 +26,19 @@ console.log(result);
2626
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators
2727

2828
//The % symbol is called the modulus operator. It returns the remainder of a division operation.
29-
// In this case, movieLength % 60 calculates the remaining seconds after dividing the total movie length by 60 (the number of seconds in a minute).
30-
// This gives us the number of seconds that do not make up a full minute in the movie length.
29+
/* In this case, movieLength % 60 calculates the remaining seconds after dividing the total movie length by 60 (the number of seconds in a minute).
30+
This gives us the number of seconds that do not make up a full minute in the movie length.*/
3131

3232
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
33-
// The expression (movieLength - remainingSeconds) / 60 calculates the total number of minutes in the movie by subtracting the remaining seconds from the total seconds
34-
// and then dividing by 60.
33+
/* The expression (movieLength - remainingSeconds) / 60 calculates the total number of minutes in the movie by subtracting the remaining seconds from the total seconds
34+
and then dividing by 60.*/
3535

3636
// e) What do you think the variable result represents? Can you think of a better name for this variable?
3737
// The variable result represents the formatted time of the movie in hours, minutes, and seconds. A better name for this variable could be movieDuration.
3838

3939
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
4040
//It will do the math perfectly for most normal positive numbers, but there are a few situations where the code will act wierdly.
41-
//1. The "Single Digit" Visual Bug (Zero-Padding)
42-
//2. Negative numbers
43-
//3.Decimal numbers (floats and non integers)
44-
//4. invalid data types (like strings, objects, etc.)
41+
/* 1. The "Single Digit" Visual Bug (Zero-Padding)
42+
2. Negative numbers
43+
3.Decimal numbers (floats and non integers)
44+
4. invalid data types (like strings, objects, etc.) */

Sprint-1/3-mandatory-interpret/3-to-pounds.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ console.log(`£${pounds}.${pence}`);
2727
// 1. const penceString = "399p": initialises a string variable with the value "399p"
2828

2929
// 2. const penceStringWithoutTrailingP = penceString.substring(0,penceString.length - 1): This removes the letter 'p' from the end of the string,
30-
// leaving just the numbers part of the string. The substring method is used to extract a portion of the string,
31-
// starting from index 0 and ending at the second-to-last character (length - 1).
30+
/* leaving just the numbers part of the string. The substring method is used to extract a portion of the string,
31+
starting from index 0 and ending at the second-to-last character (length - 1). */
3232

3333
// 3. const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); This is to ensure the numbers presented after the substring is at least 3 characters long,
3434
// if the number is shorter the computer would add '0' or '0's in front of the number to make it 3 digits long.
@@ -37,7 +37,7 @@ console.log(`£${pounds}.${pence}`);
3737
// This extracts the pounds part of the string by taking all characters except the last two.
3838

3939
// 5. const pence = paddedPenceNumberString.substring(paddedPenceNumberString.length - 2).padEnd(2, "0");
40-
// This extracts the pence part of the string by taking the last two characters and ensures that it is at least 2 characters long by adding '0' at the end
41-
// if necessary as this is because we need the decimal value.
40+
/* This extracts the pence part of the string by taking the last two characters and ensures that it is at least 2 characters long by adding '0' at the end
41+
if necessary as this is because we need the decimal value. */
4242

4343
// 6. console.log(`£${pounds}.${pence}`): This outputs the final answer in the format of pounds and allows the user to see the final result also.

0 commit comments

Comments
 (0)