-
-
Notifications
You must be signed in to change notification settings - Fork 195
WEST MIDLANDS | JAN_2025 | IFEANYI MADUBUGWU | MODULE STRUCTUING AND STORING DATA | SPRINT 1 #262
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
base: main
Are you sure you want to change the base?
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.
You seem to know the code well.
Some explanations are not clear enough, so I left you some comments and suggestions.
@@ -4,3 +4,6 @@ count = count + 1; | |||
|
|||
// Line 1 is a variable declaration, creating the count variable with an initial value of 0 | |||
// Describe what line 3 is doing, in particular focus on what = is doing | |||
|
|||
//Answer: | |||
// Line 3 is an expression which calculate the current value of count and also add to 1. |
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.
"... and also add to 1" does not quite make sense. Can you rephrase the statement?
There is a term commonly used in programming to describe operation like count = count + 1
. May I suggest feeding the code to ChatGPT to see how else the code can be described? You may be able to learn some programming terms in the process.
@@ -7,3 +7,6 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; | |||
// 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 | |||
|
|||
// Answer: | |||
// The variable num represents a randomly generated whole number between 1 and 100 (inclusive).Since minimum is 1 and maximum is 100, we generate a random number within this range using Math.random(). This function produces a decimal between 0 and 1, which we scale to the desired range.Math.floor() rounds the result down to the nearest whole number, ensuring we get an integer.Each time the code runs, num will hold a different random integer between 1 and 100. |
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.
This function produces a decimal between 0 and 1
The phrase "between 0 and 1" alone is not precise enough in program specification because
it does not state clearly whether 0 and 1 are included in the range.
One concise way to specify a range of values is to use the interval notation.
You can ask ChatGPT "how to specify a range of numbers using interval notation" to learn more about such notation.
Would you try describing the return value of Math.random()
and the value of num
using this notation?
|
||
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? | ||
// Answer: we need to remove comma from this expression Number(carPrice.replaceAll(",","")) to allow us convert number to string using .string() method. this allows mathematical expression to work correctly in java. |
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.
-
Which part of the expression converts number to string using .string() method?
-
Typo?
... in java
|
||
// e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
//Answer: this represent a format time string |
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 missed the second part of the question.
Can you think of a better name for this variable?
|
||
// d) Interpret line 4, what does the expression assigned to totalMinutes mean? | ||
// Answer: totalMinutes we remove movieLength and remainingSeconds and then divide by 60. |
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 rephrase this sentence to make it grammatically correct?
.substring(paddedPenceNumberString.length - 2) | ||
.padEnd(2, "0"); | ||
const penceNumber = parseInt(paddedPenceNumberString, 10); | ||
// Converts the string to a number to avoid issues. |
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.
What issues are you referring to?
What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? | ||
// console is an objective, while .log is a method(function) inside the objective 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.
"objective" is not the same as "object"
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.