-
-
Notifications
You must be signed in to change notification settings - Fork 219
Scotland | ITP-May-2025 | Nataliia Volkova | Module-Structuring-and-Testing-Data/Coursework/sprint 1 #509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Operation like
count = count + 1
is very common in programming, and there is a programming term describing such operation.Can you find out what one-word programming term describes the operation on line 3?
Hello CJ Yuan
Yes, the operation count = count + 1
in programming is called incrementation. In this particular case by 1. The incrementation can be 2 types: - pre-incrementation and -post-incrementation. There are short versions: count++ or ++count. Which type to use depends on our coding. In for loops we mostly use post-incrementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Phrases like "integer in range from 0 to 1" or "between 0 and 1" are not precise enough in a program specification, because they do not clearly state whether the endpoints 0 and 1 are included.
You can also use the concise and precise interval notation to describe a range of values.
For example, we can say, "Math.random()
returns a random number in the interval[0, 1)
"
So, interval notation is a much clearer and more precise way to express the range numbers by using () brackets to exclude defined numbers inside the parenthesis, and [] brackets - to include numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suppose you were not allowed to modify the statement
const cardNumber = 4533787178994213;
(that is, keep the variable's value unchanged).
How would you modify the code (through type conversion) so that you can still use.slice(-4)
to extract the last 4 digits from the given number.
I would use toString to convert the number value into a string to slice it on the further step.
Could you take this opportunity to respond to inline comments directly in their threads? It would make tracking responses easier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In JS naming convention, variable names usually begins with a lowercase letter. Names starting with an uppercase letter are used for built-in and custom data types (e.g.,
Math
)
I see, that I omitted an important part. We should avoid more than using keywords, and numbers at the start of the variables' names, but also be careful to use a capital letter at the start of the variable name. Because the convention to begin a variable name with an uppercase emphasises that we indicate a special type of value, like an object or array. These are more complicated values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You described two operations, which operation is carried out first?
We could also use the verb "remove" to describe what
carPrice.replaceAll(",","")
So, first, we had the carPrice variable with the value "10,000", then we reassigned the variable by replacing coma with "" and transformed it to a number, and the value became 10000. Yes, it will be easier to use remove
instead of replaceAll
. I got it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Between
formattedTime
andformattingTime
, which one do you think is better?
If it is a result, then formattedTime
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
No, I can't expect that the program is going to work properly without method .padEnd(2, "0")
. As .padEnd(2, "0")
allows us to get pence on the right format. Actually .padEnd(2, "0")
control whether we get a value with at least 2 characters at the end if not it adds 0
at the end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you describe in terms of whole minute, or use ChatGPT to find out how else the code can be described?
In this code:
const remainingSeconds = movieLength % 60;
const totalMinutes = (movieLength - remainingSeconds) / 60;
movieLength % 60 gets the leftover seconds
(movieLength - remainingSeconds) / 60 gives the whole minutes only
So totalMinutes is the duration in terms of whole minutes, with all partial seconds removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JS keyword
null
begins with a lowercase letter.
Got it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you type
console.log()
orconsole.log
? They have different meaning in the JS language.
So, console.log() called function with possible input in it, otherwise console.log just refers to the object (function), but doesn't call function. I typed console.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the files in the "prep" folder part of Sprint-1 exercise?
Sorry, no. Should I remove this folder on this branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You described two operations, which operation is carried out first?
We could also use the verb "remove" to describe what
carPrice.replaceAll(",","")
So, first, we had the carPrice variable with the value "10,000", then we reassigned the variable by replacing coma with "" and transformed it to a number, and the value became 10000.
1 - remove all comas, 2 - transfotm into number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for bringing my attention to important details. I made the necessary remediations.
Good job! |
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.