Birmingham | ITP-Jan-26 | Ayodeji Ayorinde | Sprint 1 | Structuring and Testing Data#1128
Birmingham | ITP-Jan-26 | Ayodeji Ayorinde | Sprint 1 | Structuring and Testing Data#1128Ayogit1 wants to merge 2 commits intoCodeYourFuture:mainfrom
Conversation
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
You missed the exercise in Sprint-1/1-key-exercises/4-random.js.
Sprint-1/1-key-exercises/1-count.js
Outdated
|
|
||
| // 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 | ||
| //Line 3 is adding 1 to the initial values of count which is 0 and reassing the new value (1+0 =1) to count |
There was a problem hiding this comment.
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?
| // This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution. | ||
|
|
||
| let initials = ``; | ||
| initials = firstName.substring(0, 1) + middleName.substring(0, 1) + lastName.substring(0, 1) |
There was a problem hiding this comment.
There are easier and more efficient ways to to extract a character at specific position/index in a string than using .substring().
Can you find out what they are and update your code accordingly?
Sprint-1/1-key-exercises/3-paths.js
Outdated
| const dir = filePath.substring(0, 44); | ||
| console.log(`The dir part of the filePath variable is ${dir}`); |
There was a problem hiding this comment.
Can you make these statements to work for any valid path? For example, they could still work correctly if we changed line 12 to
const filePath = "/Users/jacknguyen448/cyf/Module-2/Sprint-1/package.json";
Sprint-1/2-mandatory-errors/1.js
Outdated
| // Solution: | ||
| let age = 33; | ||
| let age = age + 1; No newline at end of file |
There was a problem hiding this comment.
The solution is not quite correct. Have you tried running these two lines of code?
Sprint-1/2-mandatory-errors/3.js
Outdated
| const cardNumber = "4533787178994213"; | ||
| const last4Digits = cardNumber.slice(-4); |
There was a problem hiding this comment.
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.
Sprint-1/2-mandatory-errors/4.js
Outdated
| const ClockTime12Hour = "20:53"; | ||
| const ClockTime24hour = "08:53"; No newline at end of file |
There was a problem hiding this comment.
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)
| // b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem? | ||
|
|
||
| //ANSWER: The comma in the replaceAll() function in Line 5 is missing. Put the comma back in to fix it. |
There was a problem hiding this comment.
We can more precisely describe "A comma is missing between "," and "" in the function call" as:
A comma is missing between the ___________s.
What is the programming term that belongs in the blank?
| // e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
|
|
||
| //ANSWER: The variable result represents the total lenth of the movie which shows the total hours, minutes and seconds remain in string format. |
There was a problem hiding this comment.
Can you also answer the second question in Part (e)?
| 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?
Sprint-1/4-stretch-explore/chrome.md
Outdated
| ## promt: ƒ prompt() { [native code] } | ||
| ## myName: Ayo |
There was a problem hiding this comment.
What does the function return when a user clicks "Cancel" instead of "OK"?
This reverts commit 522d1bd.
Learners, PR Template
Self checklist
Changelist
My PR addresses all the exercises in Sprint 1