Glasgow | JAN ITP-2026|Tuan Nguyen | Sprint 1 | Programming-fundamentals #1140
Glasgow | JAN ITP-2026|Tuan Nguyen | Sprint 1 | Programming-fundamentals #1140Jacknguyen4438 wants to merge 12 commits intoCodeYourFuture:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cjyuan
left a comment
There was a problem hiding this comment.
I noticed some minor inconsistency formatting in the code/comments.
Have you installed prettier VSCode extension and enabled formatting on save/paste on VSCode as recommended in
https://github.com/CodeYourFuture/Module-Structuring-and-Testing-Data/blob/main/readme.md
|
|
||
| /*Number data type represents any type of number such as integer, float number(decimal number), infinity number, etc... | ||
| In the code at line 4 the num variable are doing math function that generate a integer between variable minimum and maximum value, | ||
| the floor method behind the Math are is main purpose if to help turn value of a float number and round it up to the nearest integer. | ||
| inside the Math.floor parameter the math random method is choosing a random float number between 0 and 1 and have it multiply with the second expression | ||
| to set the range of possible value range from 0 to under 100. The last plus one to make sure the that number stay above 0(0+1) and to 100(99+1); | ||
| */ No newline at end of file |
There was a problem hiding this comment.
Phrases like "a number between X and Y" are not precise enough in a program specification, because they do not clearly state whether the endpoints X and Y are included.
We can also use the concise and precise interval notation to describe a range of values.
[,]=> inclusion(,)=> exclusion
For example, [1, 10) means, all numbers between 1 and 10, including 1 but excluding 10.
Can you practice this and use it to describe the range of numbers that could be produced in each of these sub-expressions?
Math.random()Math.random() * (maximum - minimum + 1)Math.floor(Math.random() * (maximum - minimum + 1))Math.floor(Math.random() * (maximum - minimum + 1)) + minimum
| const pence = paddedPenceNumberString | ||
| .substring(paddedPenceNumberString.length - 2) | ||
| .padEnd(2, "0"); |
There was a problem hiding this comment.
Optional challenge question (no change required):
Could we expect this program to work as intended for any valid penceString if we deleted .padEnd(2, "0") from the code?
In other words, do we really need .padEnd(2, "0") in this script? Why?
|
@cjyuan Hello Yuan, thank you for the review you give me I am very grateful for the insight. I can see that there are many section I need to fix, so I would like to notify you that I have read the PR review and in the progress of fixing it. I understand that you are very busy with other PR as well and I was radio silent do to I am doing sprint 3 of module 2 at the moment. When I finish fixing and ready to be review I will mention you again thank you. |
|
|
||
| carPrice = Number(carPrice.replaceAll(",", "")); | ||
| priceAfterOneYear = Number(priceAfterOneYear.replaceAll("," "")); | ||
| priceAfterOneYear = Number(priceAfterOneYear.replaceAll(",", "")); |
There was a problem hiding this comment.
This is fine, but the link below is worth looking into. it's an abstraction over this and will probably serve you better in the long run:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt
There was a problem hiding this comment.
@ykamal Thank you for the link. I have read through and see that it indeed more organise then the current method I write in the code. I will try to used in my course work next time.
|
Hello @cjyuan I have make change base on the review suggestion from both you and ykamal. I am ready for another PR review and please if I need to make further change please let me know |
| /* | ||
| const slashIndex = filePath.indexOf("/"); | ||
| const dir =filePath.slice(slashIndex + 0, 45) ; | ||
| const ext =filePath.slice(slashIndex + 49, 53); |
There was a problem hiding this comment.
Why keep this code? Best practice is to remove unused code to keep our code clean. And doing so also helps make code review easier.
| let dirDirectory = filePath.slice(filePath.indexOf("/"),filePath.lastIndexOf("/")); | ||
| let extDirectory = filePath.slice(filePath.lastIndexOf("/")); | ||
| console.log(`The dir part of the file is ${dirDirectory}.`); | ||
| console.log(`The ext part of the file is ${extDirectory}.`); |
There was a problem hiding this comment.
Suppose filePath is "/tmp/file.txt". Based on your understanding of the anatomy of a file path on lines 3-8, can you tell which part of the file path is considered the dir part and which part of it is considered the ext part?
When you run your code, does your code output the values you expected?
| const twelveHourClockTime = "20:53"; | ||
| const twentyFourHourClockTime = "08:53"; | ||
| console.log($12HourClockTime); | ||
| console.log($24HourClockTime); | ||
|
|
There was a problem hiding this comment.
You changed only part of the code. As such, the code won't run.
Self checklist
Changelist
I have finish all 3 section from sprint 1:
If there is some exercise or course from sprint 1 I need to fix and improve please let me know.
Questions
Yes I see that in sprint 3 I need to make multiple PR request. Could I do that in the same branch for sprint 3 or I need to make like sub branch from sprint 3 branch in order to submit?