Cape Town | 26-ITP-May | Shafiek Walker | Sprint 1 | Coursework Exercises#1387
Cape Town | 26-ITP-May | Shafiek Walker | Sprint 1 | Coursework Exercises#1387shafiekwalker7861 wants to merge 8 commits into
Conversation
Luro91
left a comment
There was a problem hiding this comment.
Good job. Most exercisers are done. I have couple of comments on some of them
| // The error is what I predicted. The slice method is not a function that can be used on numbers, only strings. | ||
|
|
||
| // Then try updating the expression last4Digits is assigned to, in order to get the correct value | ||
| const last4Digits = cardNumber % 10000; |
There was a problem hiding this comment.
This produces an error: "Uncaught SyntaxError: redeclaration of const last4Digits". HOw can you fix this?
| // The error was on line 5. The replaceAll() function call was missing the correct closing bracket/parenthesis. | ||
| // I fixed it by making the line: priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); |
There was a problem hiding this comment.
The code is working now, but the change was not adding a brackent/parenthesis. What did change?
|
|
||
|
|
||
| // d) Identify all the lines that are variable declarations | ||
| // line 1 and 2 are variable declarations because they are declared using the let keyword. |
|
|
||
| // e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
| // The variable result represents the total length of the movie in hours, minutes, and seconds. | ||
| // A better name for this variable could be "movieDuration". |
There was a problem hiding this comment.
movieDuration is already better and clearer to understand. A common name for strings is to use the prefix formatted so formattedMovieLenght would also work
| // A better name for this variable could be "movieDuration". | ||
|
|
||
| // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
| // The code works for non-negative whole numbers. Negative or decimal values may produce incorrect or unexpected results. |
There was a problem hiding this comment.
What happens if the movieLength is 3665?
| // It will help to think about the order in which expressions are evaluated | ||
| // Try logging the value of num and running the program several times to build an idea of what the program is doing | ||
|
|
||
| // Math.random() generates a random decimal, |
There was a problem hiding this comment.
What are the characteristics of the created float number?
| // Try logging the value of num and running the program several times to build an idea of what the program is doing | ||
|
|
||
| // Math.random() generates a random decimal, | ||
| // Math.floor() rounds it down, and the expression produces a random whole number between 1 and 100. No newline at end of file |
|
Hi @Luro91 , thanks for the feedback! I've addressed all of your comments: Updated the explanation about the replaceAll() change. I'd appreciate it if you could take another look. Thanks! |
|
Hi Lukas, thanks for the feedback! I've addressed all of your comments:
- Updated the explanation about the replaceAll() change.
- Corrected the list of variable declarations.
- Renamed the suggested variable to formattedMovieLength.
- Tested movieLength = 3665 and updated my explanation.
- Expanded the explanation of Math.random() and Math.floor().
I'd appreciate it if you could take another look. Thanks!
…On Wed, Jun 24, 2026 at 6:50 AM Lukas ***@***.***> wrote:
***@***.**** commented on this pull request.
Good job. Most exercisers are done. I have couple of comments on some of
them
------------------------------
In Sprint-1/2-mandatory-errors/3.js
<#1387 (comment)>
:
> // Then try updating the expression last4Digits is assigned to, in order to get the correct value
+const last4Digits = cardNumber % 10000;
This produces an error: "Uncaught SyntaxError: redeclaration of const
last4Digits". HOw can you fix this?
------------------------------
In Sprint-1/3-mandatory-interpret/1-percentage-change.js
<#1387 (comment)>
:
> +// The error was on line 5. The replaceAll() function call was missing the correct closing bracket/parenthesis.
+// I fixed it by making the line: priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", ""));
The code is working now, but the change was not adding a
brackent/parenthesis. What did change?
------------------------------
In Sprint-1/3-mandatory-interpret/1-percentage-change.js
<#1387 (comment)>
:
>
// d) Identify all the lines that are variable declarations
+// line 1 and 2 are variable declarations because they are declared using the let keyword.
Are thre other variable declarations?
------------------------------
In Sprint-1/3-mandatory-interpret/2-time-format.js
<#1387 (comment)>
:
>
// e) What do you think the variable result represents? Can you think of a better name for this variable?
+// The variable result represents the total length of the movie in hours, minutes, and seconds.
+// A better name for this variable could be "movieDuration".
movieDuration is already better and clearer to understand. A common name
for strings is to use the prefix formatted so formattedMovieLenght would
also work
------------------------------
In Sprint-1/3-mandatory-interpret/2-time-format.js
<#1387 (comment)>
:
>
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
+// The code works for non-negative whole numbers. Negative or decimal values may produce incorrect or unexpected results.
What happens if the movieLength is 3665?
------------------------------
In Sprint-1/1-key-exercises/4-random.js
<#1387 (comment)>
:
> // Try breaking down the expression and using documentation to explain what it means
// It will help to think about the order in which expressions are evaluated
// Try logging the value of num and running the program several times to build an idea of what the program is doing
+
+// Math.random() generates a random decimal,
What are the characteristics of the created float number?
------------------------------
In Sprint-1/1-key-exercises/4-random.js
<#1387 (comment)>
:
> // Try breaking down the expression and using documentation to explain what it means
// It will help to think about the order in which expressions are evaluated
// Try logging the value of num and running the program several times to build an idea of what the program is doing
+
+// Math.random() generates a random decimal,
+// Math.floor() rounds it down, and the expression produces a random whole number between 1 and 100.
What is rounded down by Math.floor?
—
Reply to this email directly, view it on GitHub
<#1387?email_source=notifications&email_token=A4CDQ6SF24YZRQRIMTDFS4D5BNMY5A5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTINJVHEYDGMBXGA22M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#pullrequestreview-4559030705>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A4CDQ6QFUULSUCML6EE2CID5BNMY5AVCNFSNUABFKJSXA33TNF2G64TZHM3TSOJSGQ2TGNRYHNEXG43VMU5TINZSGQ2DIMRUGAY2C5QC>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/A4CDQ6TAU7ETM5K65ZAZDN35BNMY5A5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTINJVHEYDGMBXGA22M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KUZTPN52GK4S7NFXXG>
and Android
<https://github.com/notifications/mobile/android/A4CDQ6W5327BFMMAKG34NW35BNMY5A5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTINJVHEYDGMBXGA22M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2K4ZTPN52GK4S7MFXGI4TPNFSA>.
Download it today!
You are receiving this because you authored the thread.Message ID:
<CodeYourFuture/Module-Structuring-and-Testing-Data/pull/1387/review/4559030705
@github.com>
|
Learners, PR Template
Self checklist
Changelist
Completed all Sprint 1 mandatory exercises, including implementing functions, interpreting code, and debugging. Tested all solutions before submitting.