-
-
Notifications
You must be signed in to change notification settings - Fork 220
London_ITP_Jan2025| Aung_Ye_Kyaw |Module-Structuring-Testing-Data |Coursework/sprint 1 #319
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.
You have both sprint 1 and sprint 2's work in here - please move sprint 2's to another pull request and get it reviewed separately, I have only reviewed sprint 1's here.
In general things are looking decent here, but I'd encourage you to think about the meaning in the problem domain of the code, not just in JavaScript. If we're dealing with time, or money, what do values/operations represent thinking about time/money, not just strings/variables.
Sprint-1/1-key-exercises/3-paths.js
Outdated
const ext = ; | ||
const dir = filePath.slice(0,lastSlashIndex+1); | ||
console.log (`The dir part of the file path ${dir}`); | ||
const ext = filePath.slice(-3); |
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 works, but it is not very general. If the filePath
variable contained a file named hello.jpeg
, I don't think it would return the correct result. Can you think how to solve this which would work regardless of the number of characters in the extension?
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.
Thanks for the feedback .
I fixed the filePath for general purposes. Please check and provide feedback.
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.
Looks great, much more general - thanks!
What do you think would happen if the filename didn't contain any .
s? What do you think should happen in that case?
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.
It will return the whole file part .
LastIndexof (".") will return -1 if there are no "." in the file path.
So the slice method will cut the string from the start .
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.
Do you think this is a good answer to the question "What is the extension of this file"? Or is there some better answer we could give?
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.
It will return the whole file path . I think it should raise an error message ("incorrect file format ").
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; | ||
|
||
|
||
const step1 = Math.random(); // get random number >=0 & <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.
I think this is a good explanation, breaking it down into steps is really useful, but can you also talk about what the whole thing does, as well as just the separate steps?
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.
As a whole thing this program is for testing Operator precedence , in order to know which operation performs fast . I answered as per I understand :)
Please guide me if I am in the wrong way .. Thank you .
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.
Precedence is one of the things being tested here, but general code understanding is too :) Can you try to also describe this code in terms of the problem?
e.g. in the initials exercise you could describe in problem terms we're "Making a string of the first letter of each name" (whereas in programming terms we'd maybe say "We're making variables storing the first character of each name, and then concatenating them together into one variable")
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.
We are making a variable storing the result of round down to nearest largest number of the random numbers multiplied by the result of maximum number subtract minimum , after that adding by 1 and then adding with minimum value.
// 1. const penceString = "399p": initialises a string variable with the value "399p" | ||
// 2. const penceStringWithoutTrailingP = penceString.substring(0,penceString.length - 1) : removing p by using substring method. | ||
// 3.const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); : adding 0 to the start from the left side in case of penstring have 2 numbers only | ||
// 4. const pounds = paddedPenceNumberString.substring(0,paddedPenceNumberString.length - 2); : getting the first letter from the 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.
The first letter? What's in the string? Why would we be getting the first letter from 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.
Getting the first character from the string to get the pound value from the given string penny .
pop up dialog box with text box to accept user input | ||
|
||
What is the return value of `prompt`? | ||
string is the return value of prompt |
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 is returned if the user presses cancel?
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.
null value if user press cancel or enter without typing any value in text box.
Answer the following questions: | ||
|
||
What does `console` store? | ||
store data for a while |
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 do you mean by "a while"? Where does it store data?
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.
It stores data temporarily on the browser's memory when it is open and disappear when refreshing the browser .
|
Let's take a look at an example from 3-to-pounds: You wrote: "removing p by using substring method." This is correct. But what does that mean? It gives us a string containing the number of pence, which we can then convert to a number if we want. That meaning - that removing the p gives us the number of pence, is really useful to think about. Thinking not just about what we're doing in terms of code, but in terms of the problem. The language of javascript is all about strings and numbers. The language of this problem is about numbers of pence and pounds. Similarly: "get the last two letter and add zero in case if there is only one letter." Again, this is true, but in problem terms we're getting the number of pence after taking away all of the whole pounds. In the future, try to answer questions in both terms - what are we doing in code, and what are we doing in the problem :) |
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.
Some good improvements, well done!
let initials = ``; | ||
// declaring variables for each name and take out fist character | ||
|
||
let fname_initials = `${firstName.charAt(0)}`; |
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 JavaScript we tend to use camelCase not snake_case for variable names, so this would be fnameInitials
rather than fname_initials
. This isn't a big deal - the code works either way, but it's a convention we tend to stick to.
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.
Thanks for the advice .
I have changed all the variable names as camelCase.
let initials = ``; | ||
// declaring variables for each name and take out fist character | ||
|
||
let fname_initials = `${firstName.charAt(0)}`; |
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.
Because charAt
returns a string, we don't need to interpolate this into a string as well
let fname_initials = `${firstName.charAt(0)}`; | |
let fname_initials = firstName.charAt(0); |
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.
Remove string interpolate.
let initials = ``; | ||
// declaring variables for each name and take out fist character | ||
|
||
let fname_initials = `${firstName.charAt(0)}`; |
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 string will contain exactly one character, so initial
is probably a better than than initials
, which suggests it contains more than one :)
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.
noted and changed as per suggestion . Thank you.
Sprint-1/1-key-exercises/3-paths.js
Outdated
const ext = ; | ||
const dir = filePath.slice(0,lastSlashIndex+1); | ||
console.log (`The dir part of the file path ${dir}`); | ||
const ext = filePath.slice(-3); |
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.
Looks great, much more general - thanks!
What do you think would happen if the filename didn't contain any .
s? What do you think should happen in that case?
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.
Good improvements!
const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; | ||
|
||
|
||
const step1 = Math.random(); // get random number >=0 & <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.
Precedence is one of the things being tested here, but general code understanding is too :) Can you try to also describe this code in terms of the problem?
e.g. in the initials exercise you could describe in problem terms we're "Making a string of the first letter of each name" (whereas in programming terms we'd maybe say "We're making variables storing the first character of each name, and then concatenating them together into one variable")
Sprint-1/1-key-exercises/3-paths.js
Outdated
const ext = ; | ||
const dir = filePath.slice(0,lastSlashIndex+1); | ||
console.log (`The dir part of the file path ${dir}`); | ||
const ext = filePath.slice(-3); |
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.
Do you think this is a good answer to the question "What is the extension of this file"? Or is there some better answer we could give?
// 5 | ||
// b) How many function calls are there? | ||
|
||
//no function calls |
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.
There are also functions that the user didn't define, but that already exist in the language.
A function call generally looks like a pair of ()
s after a name (possibly with some values between the ()
s).
Do you see any places in this code where there's a name, and then a (
, then maybe some values, then a )
?
This would still be a function call, even if the user didn't define the function themselves.
Checked the feedback and updated/modified the requirements . Ready for review and provide feedback . Thank you |
Could I change the status to Complete .? :) |
} | ||
|
||
const currentOutput = formatAs12HourClock("08:00"); | ||
const currentOutput = formatAs12HourClock("08:30"); |
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've correctly identified an issue here, and written a good test for it, but the test is currently failing. Can you fix the code so the test passes?
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 change need to submit on Sprint-2 ..Shall I update on spring-2 ?
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.
Aah good call, sorry I didn't realise there were still two sprints of work in here (this is one of the reasons it can be useful to remove the incorrectly added work from one branch when you put it in another :))
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 for your guidance and feedback .I will update to Sprint-2 by fixing the code . :)
Thank you so much .
Nearly! I left two last comments! Thanks for putting in the work to see this through! |
I have followed the points as per read me file and put the answer in each file.
Please kindly review and let me know the requirements.
Thanks for your time & support ..