-
-
Notifications
You must be signed in to change notification settings - Fork 262
West Midlands | 25 Sep ITP | Iswat Bello | Sprint 1 | Module Structuring and Testing Data #744
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
… and explain Number(...replaceAll(...)) usage
Sprint-1/1-key-exercises/3-paths.js
Outdated
| const ext = ; | ||
| const dir = filePath.slice(0,lastSlashIndex) ; | ||
| console.log(dir); | ||
| const ext = filePath.slice(lastSlashIndex + 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.
Here the aim is the store the ext part. if you look at the diagram, the ext part doesn't include the string 'file'. so how would you store just the ext part?
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.
Hi @tenzyns.
Thank you for the feedback. I’ve updated the code to extract only the extension part by slicing from the last dot to the end and storing the value in the ext variable. The updated code is shown below:
const lastDotIndex = base.lastIndexOf(".");
const ext = base.slice(lastDotIndex) ;
| // For example, 37.6 becomes 37, and 99.9 becomes 99. | ||
|
|
||
| // + minimum | ||
| // Variable minimum is added to the expression "Math.floor(Math.random() * (maximum - minimum + 1))" and the the value is stored inside the variable num |
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.
Why do you think the variable minimum is added to the expression?
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.
Hi @tenzyns.
I added the variable minimum to the expression inorder to shift the range so the random number starts from the minimum value instead of 0. Without it, the result would be between 0 and (maximum - minimum), but adding minimum ensures it’s between minimum and maximum (inclusive).
Sprint-1/2-mandatory-errors/4.js
Outdated
| // This error means that Javascript was unable to read the code because a variable name cannot start with a number | ||
| // I can fix this code by removing the numbers from the start of the variable name | ||
|
|
||
| const HourClockTime = "20:53"; |
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's not incorrect but to keep in mind, its convention to capitalise variables which are class name and constructor name in Javascript.
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.
Hi @tenzyns.
Thank you for the feedback! I’ll follow the convention and use camelCase for regular variables going forward.
I’ve also updated my code by renaming the two variables using camelCase.
- Use lastIndexOf('.') and slice() to return '.txt'
|
Nice work @Iswanna |
Learners, PR Template
Self checklist
Changelist
In this pull request, I worked through the tasks in the following directories:
For the 1-key-exercises, I completed short JavaScript programs and tasks. When I came across syntax or code I didn’t recognize, I looked it up in the documentation to understand how it worked.
For the 2-mandatory-errors exercises, I ran each file in the errors directory using Node.js to identify and understand the error messages. I then explained the cause of each error.
For the 3-mandatory-interpret exercises, I analysed small JavaScript programs that included unfamiliar syntax and operators. I used the MDN Web Docs to look up and understand new concepts, and used console.log() statements to test and interpret variable values.
Questions
Hi. Please could you review my PR? I’d really appreciate your feedback.